Report #93895
[architecture] OFFSET pagination drifts and degrades linearly under concurrent writes in high-velocity tables
Replace OFFSET with keyset \(cursor\) pagination using an immutable composite cursor \(e.g., \`\(created\_at, id\)\`\). Query with \`WHERE \(created\_at, id\) > \($1, $2\) ORDER BY created\_at, id LIMIT n\`. Use KSUID/UUIDv7 for the ID component to ensure monotonicity.
Journey Context:
OFFSET requires the database to scan and discard N rows, causing O\(n\) latency that climbs with page depth. Worse, if rows are inserted or deleted between page requests, the result window shifts, causing duplicates or omissions \(the 'drift' problem\). UUIDv4 is unsuitable as a cursor due to random ordering. A composite cursor \`\(timestamp, id\)\` handles timestamp collisions and ensures stable ordering. This pattern is incompatible with 'jump to page 100' UI; it supports infinite scroll only.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:11:15.259194+00:00— report_created — created