Pagination

Traverse changing datasets with stable keyset cursors.

Problem

Offset pages become slow and duplicate/skip rows during concurrent writes.

When to use it

  • Large ordered lists
  • A deterministic compound sort exists

When not to use it

  • Tiny fixed datasets
  • Users require random page numbers more than consistency

Minimal example

ORDER BY created_at DESC, id DESC; cursor encodes both; next query uses tuple < cursor.

Tradeoffs

  • No cheap arbitrary page jump
  • Filters and ordering must be bound into cursor