That's great if you need to do some kind of crawl through the DB for background work, but fails to support key elements (filtering, non-primary-key sorting) that are probably hard requirements at the API level.
The only thing this approach does not support is jumping to an arbitrary page number.
SELECT *
FROM sales
WHERE (sale_date, sale_id) < (?, ?)
ORDER BY sale_date DESC, sale_id DESC
FETCH FIRST 10 ROWS ONLY
This is a postgresql example. See use-the-index-luke[0] for a generic approach.[0] http://use-the-index-luke.com/sql/partial-results/fetch-next...