Pagination

Must: Support Pagination

Access to lists of data items must support pagination for best client side batch processing and iteration experience. This holds true for all lists that are (potentially) larger than just a few hundred entries.

There are two page iteration techniques:

The technical conception of pagination should also consider user experience related issues. As mentioned in this article, jumping to a specific page is far less used than navigation via next/previous page links. This favours cursor-based over offset-based pagination.

Should: Prefer Cursor-Based Pagination, Avoid Offset-Based Pagination

Cursor-based pagination is usually better and more efficient when compared to offset-based pagination. Especially when it comes to high-data volumes and / or storage in NoSQL databases.

Before choosing cursor-based pagination, consider the following trade-offs:

  • Usability/framework support:

    • Offset / limit based pagination is more known than cursor-based pagination, so it has more framework support and is easier to use for API clients
  • Use case: Jump to a certain page

    • If jumping to a particular page in a range (e.g., 51 of 100) is really a required use case, cursor-based navigation is not feasible
  • Variability of data may lead to anomalies in result pages

    • Offset-based pagination may create duplicates or lead to missing entries if rows are inserted or deleted between two subsequent paging requests.
    • When using cursor-based pagination, paging cannot continue when the cursor entry has been deleted while fetching two pages
  • Performance considerations - efficient server-side processing using offset-based pagination is hardly feasible for:

    • Higher data list volumes, especially if they do not reside in the database’s main memory
    • Sharded or NoSQL databases
  • Cursor-based navigation may not work if you need the total count of results and / or backward iteration support

results matching ""

    No results matching ""