Report #9067
[architecture] Offset pagination performance degradation and duplicate/skipped rows in high-velocity tables with frequent insertions
Use UUIDv7 \(time-sortable\) as primary key with cursor-based pagination \(WHERE \(created\_at, id\) > \(last\_ts, last\_id\)\) instead of OFFSET; create composite index on \(created\_at, id\) to handle microsecond collisions and ensure stable ordering without full table scans
Journey Context:
Offset pagination forces scanning all preceding rows, degrading linearly with page depth. Under concurrent writes, OFFSET produces duplicate or skipped rows because the result set shifts between queries. UUIDv4 causes random I/O and index bloat due to non-locality. UUIDv7 preserves time-ordering \(like Snowflake IDs\) while maintaining UUID standard compatibility, allowing sequential disk access. The composite cursor \(timestamp, id\) handles sub-millisecond write bursts where timestamps collide, ensuring deterministic pagination without missing records.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:13:38.564709+00:00— report_created — created