Database Pagination: Cursor vs Offset

Offset pagination is the textbook answer; cursor pagination is the production answer. The difference matters at any meaningful scale.

Why pagination matters

Pagination looks simple until you scale. The two paradigms have wildly different performance characteristics; the choice locks in for years.

Offset pagination

Cursor pagination

Cursor pagination uses a stable sort key as the boundary marker. Each page filters on the previous cursor; performance stays constant regardless of page depth.

API-design implications

The pagination paradigm leaks into the API. Cursor and offset APIs look different on the wire; once shipped, the contract is hard to change.

Antipatterns

What to do this week

Three moves. (1) Apply this pattern to your slowest production endpoint. (2) Measure p99 before/after. (3) Document the win and ship the runbook so the team can reproduce.