Offset Pagination Can Repeat or Skip Rows; Cursors Help but Have Limits
A common pagination problem occurs when a feed is changing: a page can show the same row twice after an insertion, or skip a row after a deletion, even with a valid ORDER BY. The cause is that OFFSET counts rows in the current result, not rows already seen. Keyset pagination, which continues after the last row's sort values, avoids these shifts by using a stable boundary. However, a cursor still reads live data, so it cannot guarantee a snapshot of everything that existed at one moment. The article demonstrates both the fix and its limits using six rows in SQLite and a small Node.js script.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in