Offset pagination
Offset pagination uses a limit and an offset, like skip twenty rows then take ten. It is simple and lets clients jump to any page. But it has two real problems at scale.
- The database often scans and discards all skipped rows, so deep pages get slow.
- If rows are inserted or deleted while paging, items can be skipped or repeated because positions shift.
Cursor pagination
Cursor pagination remembers a stable pointer to the last item, usually an indexed sorted value like a timestamp or id. The next request asks for rows after that cursor.
- Queries stay fast because they seek into an index instead of counting offsets.
- Concurrent inserts do not shift the window, so results stay stable.
- The tradeoff is you cannot jump to an arbitrary page number.
Picking one
Use offset for small bounded data and admin tables where jumping pages matters. Use cursors for infinite scroll feeds and large fast changing datasets where stability and speed win.
Key idea
Offset pagination is simple but drifts and slows on deep pages while cursor pagination seeks an indexed pointer for stable fast forward only paging.