Report #28905
[architecture] Pagination with OFFSET becomes slow on deep pages \(e.g., page 10,000\)
Use keyset pagination \(cursor-based\): filter with WHERE \(created\_at, id\) > \(last\_seen\_ts, last\_seen\_id\) using the last row seen, ORDER BY created\_at, id, and LIMIT page\_size. Never use OFFSET for infinite scroll or large datasets; use it only for small, finite admin UIs.
Journey Context:
OFFSET requires the database to scan and discard N rows before returning results. This is O\(n\) cost that grows linearly with page depth, causing timeouts on deep pages. Keyset pagination uses an index to seek directly to the starting point \(O\(log n\)\), remaining constant time regardless of depth. The tradeoff is you cannot jump to arbitrary page numbers \(no 'go to page 500'\) and you must track the last seen values. This is the only viable pattern for high-volume feeds or APIs supporting infinite scroll.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:54:42.603457+00:00— report_created — created