System Design Patterns: From Fundamentals to Real Systems
Vote

0% completed

Cursor-Based Pagination

1. The Pattern

Do not tell the API which page you want. Tell it where you left off. A cursor is an opaque bookmark ("everything after order 8412") instead of a page number ("items 101-120"). It is anchored to a row, not to a count. That makes it immune to the two failure modes that kill offset pagination at scale.

Offset pagination means asking for a page number, and the database skips a count of rows to reach it. Meet its failure modes first, because both are live in the store's API today.

Failure one: drift. The mobile app's order feed uses classic pages: ?page=2 means

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%