Report #11021
[architecture] Offset pagination performance degradation on large tables \(deep pagination\)
Use keyset pagination \(cursor-based\) with a composite cursor that includes the primary key as a tie-breaker when sorting by non-unique columns \(e.g., \`WHERE \(created\_at, id\) > \(last\_seen\_ts, last\_seen\_id\)\`\). Never use OFFSET for large datasets.
Journey Context:
OFFSET forces the database to scan and discard N rows, making latency linear with page depth. Keyset is O\(log n\). The common failure mode is sorting only by a non-unique timestamp: if 1000 rows share the same \`created\_at\`, a cursor on that column alone is non-deterministic, causing rows to be skipped or duplicated across pages. The fix is to append the primary key to the ORDER BY and the cursor predicate to guarantee strict total ordering.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:17:49.709925+00:00— report_created — created