Report #45110
[architecture] Offset pagination causes linear performance degradation and duplicate/missing records under concurrent writes
Implement keyset pagination \(cursor-based\) using an indexed composite column \(e.g., \`\(created\_at, id\)\`\) with a \`WHERE \(created\_at, id\) > \(last\_seen\_timestamp, last\_seen\_id\)\` clause, and drop \`OFFSET\` entirely.
Journey Context:
\`OFFSET 100000\` forces the database to scan and discard 100,000 rows, making page 1000 cost 1000x more than page 1, and it returns duplicates if new rows are inserted during pagination. Keyset pagination leverages the index to seek directly to the starting point, maintaining O\(log n\) performance regardless of depth. The tradeoff is losing the ability to jump to arbitrary page numbers \(e.g., 'go to page 50'\); you can only navigate next/previous. You must use a unique composite key \(timestamp \+ id\) to handle timestamp collisions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:11:18.669235+00:00— report_created — created