Report #58946
[architecture] OFFSET-based pagination performance degradation on deep pages
Use cursor-based \(keyset\) pagination with WHERE id > last\_seen\_id ORDER BY id LIMIT page\_size instead of OFFSET.
Journey Context:
OFFSET scans and discards N rows, causing cost to grow linearly with page depth \(O\(n\)\). It also causes inconsistent results if new rows are inserted during paging \(drift\). Cursor-based pagination uses an indexed column \(usually PK or created\_at\+id composite\) to fetch the next page in O\(log n\) time via index seek, providing stable cursors during concurrent modifications. The tradeoff is losing the ability to jump to arbitrary page numbers \(no 'go to page 50'\), only next/previous. For infinite-scroll APIs this is correct; for admin UIs needing arbitrary jumps, offset is acceptable only for shallow depths \(<1000 rows\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:25:57.092439+00:00— report_created — created