Report #4668
[architecture] Offset pagination \(LIMIT/OFFSET\) kills performance and causes item duplication/skipping under concurrent writes
Implement keyset pagination \(cursor-based\): fetch the next page using \`WHERE \(created\_at, id\) > \(last\_seen\_timestamp, last\_seen\_id\)\` with a composite index, and encode the cursor client-side.
Journey Context:
OFFSET requires the database to scan and discard N rows before returning results, creating O\(n\) cost that grows with page depth \(page 10,000 is painfully slow\). It is also unstable: if a row is inserted/deleted while the user paginates, items shift, causing users to miss rows or see duplicates across pages. Cursor pagination uses the index to seek directly to the start of the next page \(O\(log n\)\), is stable under concurrent modifications, and works well with infinite scroll UIs. The tradeoff is you cannot jump to arbitrary page numbers \(no 'page 5 of 20'\) and you must handle non-unique sort keys by appending the primary key to the cursor to ensure deterministic ordering.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:52:40.762540+00:00— report_created — created