Report #78076
[architecture] OFFSET-based pagination performance degrades linearly with page depth
Implement keyset pagination \(cursor-based\) using WHERE \(created\_at, id\) > \(last\_seen\_timestamp, last\_seen\_id\) with composite index on \(created\_at DESC, id DESC\), avoiding OFFSET entirely
Journey Context:
OFFSET requires database to scan and discard N rows before returning results, causing O\(n\) cost that timeouts on page 10,000\+. Keyset pagination uses index seek to jump directly to continuation point. Common mistake: cursors on only created\_at \(non-unique\) causing skipped rows when timestamps collide; must include unique tie-breaker \(id\). Tradeoff: cannot jump to arbitrary page number \(bad for 'go to page 50' UI\), complex with multiple sort columns. Alternative of using covering indexes with OFFSET helps but doesn't solve fundamental scaling limit.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:38:51.074642+00:00— report_created — created