Pagination done right
How to page through large result sets in APIs and databases: why offset pagination slows down and skips rows, keyset (cursor) pagination with stable ordering and opaque cursors, page size limits, total counts, infinite scroll versus numbered pages, and API response formats.
CodexBash, , 5 min read
No API should return a million rows in one response, so every list endpoint needs pagination: returning results a page at a time. The obvious approach, LIMIT 20 OFFSET 40, works fine in development and then slows to a crawl and starts showing duplicate or missing items in production. This article explains why, shows the better approach, keyset (cursor) pagination, and covers the API design details that make paging pleasant for clients.
Sign in to read the rest
The whole 5 minute article is free with an account, along with every problem, lesson and tutorial. No card.