← systems library
data & storage

API Pagination: Offset vs Cursor

Offset is simple but slow and unstable; cursor (keyset) is an index seek that’s stable under writes.

Offset / limit — simple but fragile Cursor / keyset — stable & fast offset way query cost cursor way query result Clientpage through a list GET ?offset=40&limit=20page 3 DB: scan 60, discard 40no index help Slow at depth · shifts on insertskips / repeats GET ?after=<cursor>&limit=20opaque key DB: WHERE id > cursorindex seek Fast · stable under writesno random jump OWNERSHIP Client Offset / limit Cursor / keyset Database API Pagination: Offset vs CursorOffset is simple but slow and unstable; cursor (keyset) is an index seek that’s stable under writes.
↓ Download SVG ↓ Download spec

Considerations