Keyset pagination
Paging by remembering the sort key of the last row returned and asking for rows after it (WHERE id > ? ORDER BY id LIMIT ?), instead of skipping rows with OFFSET. Each page costs the same, and inserts or deletes elsewhere do not shift what you see.
Minimal example
SELECT id, name FROM restaurants
WHERE id > ?
ORDER BY id
LIMIT 21;Learn this concept
Lesson 2.9 · Keyset (cursor) paginationUsed in exercises
Exercise 2.10 · GET /v1/restaurants with a cursor Exercise 2.19 · Restaurant list integration suite Exercise 2.22 · GET /v1/restaurants: signed cursors Exercise 2.24 · GET /v1/restaurants: search by name Exercise 2.26 · GET /v1/restaurants: sort by distancePrerequisite conceptsEXPLAIN
RelatedOpaque cursor