jargon

Comparison

Cursor paginationvsOffset pagination

Cursor pagination

you return an opaque token pointing at the last row, so page fifty costs the same as page one and nothing shifts under the client.

Paginating by an ordered key rather than a numeric offset. It is stable under concurrent inserts and deletes, and each page is an indexed seek rather than a scan. The cost is that you cannot jump to an arbitrary page number, which is almost always an acceptable trade for an API.

Full entry →

Offset pagination

you ask for page 400 and the database dutifully reads and discards the first eight thousand rows to get there.

Paginating with a row offset and a limit. It is trivially easy and supports arbitrary page jumps, which is why it is everywhere. It degrades linearly with depth, and rows inserted or deleted between requests shift the window, so clients can skip or repeat items.

Full entry →

Related comparisons