4 ms·
It's true that it is non-trivial to get this right with SQL directly. If SQL (or SQL tooling) had some abstraction for such a clause it would be easier to under
by lukaseder 13y ago
It's true that it is non-trivial to get this right with SQL directly. If SQL (or SQL tooling) had some abstraction for such a clause it would be easier to understand that the paging predicates can be added dynamically, based on the `ORDER BY` clause.
In other words, even if the linked Stack Overflow question makes a very simple example, all you need is a unique sort order (i.e. containing at least one key, not necessarily the primary key) and then filter by that.
This is described here: http://blog.jooq.org/2013/10/26/faster-sql-paging-with-jooq-using-the-seek-method/ http://blog.jooq.org/2013/10/26/faster-sql-paging-with-jooq-...
E.g.
SELECT player_id, first_name, last_name, score
FROM players
WHERE game_id = 42
-- assuming 15 is Jack Harris's player_id
AND (score, player_id) < (949, 15)
ORDER BY score DESC, player_id DESC
LIMIT 10;