Performance Intermediate By Samson Tanimawo, PhD Published Oct 20, 2026 9 min read

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

User scrolls; query needs page 2, 3, etc.

Two paradigms; very different performance.

Offset pagination

Cursor pagination

Cursor: WHERE id > last_seen_id LIMIT 10. Constant time per page.

Implementation: store cursor; pass back to client.

Slightly more complex; necessary at scale.

API-design implications

Cursor APIs return next-cursor with each page.

Offset APIs return total-count + page numbers.

Each API style implies a backend pagination choice; cannot easily switch later.

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.