Pagination with a Page Number and Offset

Page-number pagination translates a selected page into a range of positions in a declared order.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Calculate one example
  2. Check stable ordering
  3. Trace how one insertion shifts the second page
  4. Keep a deterministic order and describe consistency limits

Calculate one example

With ten results per page and one-based page numbers, page three starts at offset twenty. The next ten positions follow ordinary zero-based indexing.

Check stable ordering

When several records share a displayed date, include an unambiguous tie rule. A new insertion can still move offsets between requests. Stable sorting explains how equal keys retain source order when that source is fixed.[1][2]

Trace how one insertion shifts the second page

At page size three, sorted records A through F produce first page A,B,C and second page D,E,F. If X is inserted before A before the second request, offset three now returns C,D,E. One record repeats and F moves to another page. See cursor pagination.

Start: A B C
D E F
After insert: X A B
C D E
F
Existing second-page offset still begins at index 3

Keep a deterministic order and describe consistency limits

Stable tie-breaking is needed even without concurrent changes. A snapshot can keep results steady, while a live view can shift. Test a page boundary with tied sort values and an inserted record.

References

  1. IETF, RFC 9110: HTTP Semantics ↩
  2. WHATWG, HTML Living Standard: Forms ↩