offset pagination
Paging by saying how many items to skip, such as ?limit=2&offset=4.
In more detail
It is easy to read and debug, but when rows are inserted or deleted between requests, items shift between pages and can repeat or be skipped. Large offsets are also slow, because the database still reads and throws away every skipped row.
Example
GET /tasks?limit=2&offset=4Related terms
- cursor pagination — Paging by remembering the position of the last item seen and asking for items after it, such as ?after=2&limit=2.
- pagination — Splitting a large collection into bounded pages, each with a way to ask for the next one.
- pagination drift — A pagination bug where walking every page returns some items twice or misses some altogether.
- keyset pagination — Paging by remembering the last key the reader saw and asking for rows after it, which does not drift.
- LIMIT — A clause that returns at most a given number of rows, optionally after skipping a number of rows with OFFSET.
Taught in
- Pagination Strategies — Modern API Architecture: REST, GraphQL & gRPC
- Sorting Results — Modern API Architecture: REST, GraphQL & gRPC
- Ordering And Limiting Results — PostgreSQL, Indexing & Relational Data Modeling