Report #71809
[architecture] OFFSET-based pagination performance degradation and inconsistency on high-churn tables
Implement keyset pagination \(seek method\) using 'WHERE \(sort\_col, id\) > \(last\_val, last\_id\)' with an opaque cursor \(base64-encoded tuple\). Never expose internal IDs directly if security-sensitive. Ensure composite index on \(sort\_col, id\).
Journey Context:
OFFSET is O\(n\) cost - must scan and discard N rows. At 1M\+ rows, page 1000 becomes seconds. Also, OFFSET is inconsistent under concurrent inserts \(user sees duplicate items across pages\). Keyset pagination \(SQL:2011 FETCH FIRST, or manual WHERE clause\) is O\(log n\) with proper index. Tradeoffs: Cannot jump to arbitrary page \(no 'go to page 50'\), only next/previous. Requires unique tie-breaker \(id\) in sort. Cursor must be opaque to prevent tampering \(predictable cursors leak data\). Alternative: Search after with Elasticsearch/OpenSearch for complex sorts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:06:47.958893+00:00— report_created — created