Keyset Pagination
Keyset pagination selects the next page by comparing ordered key values with the last returned row. It avoids treating a changing row offset as identity. The order must be deterministic, usually with a unique tie-breaker, and the predicate must match that order.
For ascending non-null updated_at and order_id, resume with updated_at > t OR (updated_at = t AND order_id > k), then ORDER BY updated_at, order_id and a page limit. Sorting by both columns while filtering only updated_at > t skips remaining rows tied at t.
Use a consistent read for a fixed extraction. A cursor does not discover a row that commits later behind it, or preserve an intermediate version already overwritten. Mutable sort keys, NULL ordering and descending columns need explicit rules; ingestion still needs a visibility and recovery protocol.
Further reading
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
