Report #15701
[architecture] Offset pagination performance degradation and skipped rows under concurrent writes
Implement keyset pagination \(cursor-based\) using last-seen values of indexed columns instead of LIMIT/OFFSET
Journey Context:
OFFSET scans and discards all preceding rows, causing linear O\(n\) cost that degrades as users paginate deeper \(page 10000 of 20 rows costs 200020 row reads\). Under concurrent writes, OFFSET produces duplicate or skipped rows as the underlying data shifts between pages. Keyset pagination uses WHERE id > last\_id ORDER BY id LIMIT n, which performs O\(log n\) index seeks. Tradeoffs: Cannot jump to arbitrary page numbers \(only next/previous\), requires deterministic sort order on unique columns, and cursors exposed to clients must be encrypted/signed to prevent users from crafting arbitrary query ranges.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:48:28.921549+00:00— report_created — created