Skip to content
Commitwise
Menu

Keyset pagination

Also called: Seek pagination

Paging by continuing after the last row's sort key instead of skipping a number of rows with OFFSET.

Definition

The next page asks for rows that come after the last one returned, for example where (created_at, id) is less than the last values. With an index on the sort columns, every page costs the same, and inserts between requests don't cause duplicates or gaps. It supports next and previous, but not jumping to an arbitrary page number.

In practice

GET /orders?after=<cursor> returns the next 50 orders older than the last one the client saw.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.