Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How to Choose Between Cursor and Offset Pagination

Cursor pagination suits sequential traversal of large collections; offset pagination suits numbered pages and direct jumps. The right choice depends on ordering, indexes, workload, and consistency needs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use cursor (keyset) pagination to move sequentially through a large or frequently changing collection, especially when deep-page query cost matters. Use offset pagination when people need numbered pages or direct jumps, provided the cost of skipping rows is acceptable. If your interface needs both, combine cursors for next/previous navigation with offsets for explicit page jumps.

How the two methods locate a page

Offset pagination counts from the beginning

An offset query asks for rows after skipping a specified number of rows, often with a limit for the page size. That maps naturally to numbered pages: page 20 is a position you can request directly. The trade-off is that the database may still process the skipped entries, and the work can grow as the offset gets larger. Microsoft’s Entity Framework Core pagination guidance describes this increasing work for skipped rows.

As an Amazon Associate I earn from qualifying purchases.

Cursor or keyset pagination continues from a boundary

Keyset pagination records the ordered values from the last row on the current page, then asks for rows beyond those values. An API may package that continuation position in an opaque cursor token or URL. With a suitable index, the database can seek from the boundary instead of repeatedly skipping a growing prefix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The distinction is practical: offsets represent a position in the result set; cursors represent where traversal should continue. Cursor pagination is therefore a good fit for “load more” feeds and sequential exports, but it does not inherently identify an arbitrary numbered page.

Which one should you use?

Need Better starting point Why Trade-off
Jump to page 20 or show numbered page controls Offset Direct page-position semantics are simple. Deep offsets can require processing skipped rows, and changes to earlier rows can shift page positions.
Load successive pages through a large feed or export Cursor/keyset Continues from the last ordered key rather than skipping an ever-growing prefix. Requires stable ordering, cursor handling, and suitable indexes.
Traverse a collection while it is changing Usually cursor/keyset Less sensitive to insertions or deletions before the last-seen boundary. Does not by itself provide a frozen, point-in-time snapshot.
Support both page jumps and efficient neighboring-page navigation Hybrid Use cursors for next/previous and offsets for explicit jumps. Keep the ordering and behavior consistent between navigation modes; jumps still incur offset costs.

Why changing data can disrupt pagination

With offset pagination, each request counts from the current result set. If a row is inserted or deleted before the next requested offset, later rows shift position; a client can see a repeated row or miss one. Microsoft Graph’s collection guidance also warns that changes during pagination can produce missing or repeated results.

Keyset pagination is less sensitive to changes below the last-seen key: it resumes beyond that boundary rather than counting from the start. But neither method alone guarantees that every page reflects one consistent snapshot. For an audit or export that must be complete as of a precise moment, specify the snapshot or consistency contract separately from the pagination mechanism.

Make ordering deterministic before adding pagination

Every paginated query needs a fully unique order. If records can share a sort value, add a unique tie-breaker such as an ID. Microsoft’s EF Core documentation states: “Regardless of the pagination method used, always make sure that your ordering is fully unique.” Without that, rows tied at the page boundary can move unpredictably between requests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For keyset pagination, retain every ordered value from the last item and use all of them in the continuation condition. For example, for ascending order by created_at and then id, continue with:

Rank #3
created_at > :last_created_at
OR (created_at = :last_created_at AND id > :last_id)

For descending traversal, reverse the comparisons and ordering consistently. The cursor must represent the complete ordering boundary, not just the first sort value.

Indexes and query design affect cursor performance

Keyset pagination is not automatically fast simply because it uses a cursor. Indexes should align with the ordered columns and relevant filters so the database can locate the continuation boundary efficiently. Microsoft’s EF Core guidance emphasizes that proper indexing is vital and recommends indexes corresponding to the pagination ordering. Validate the actual query plan for your database, filters, data distribution, and workload before claiming a performance advantage.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Handle API continuation tokens according to the contract

An API cursor is usually an opaque continuation token, not a raw database cursor. Pass the server-provided token or URL back unchanged; do not construct or edit it. Keep filters and sort order consistent across requests, and follow that API’s page-size and continuation rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, Microsoft Graph says clients “MUST treat the nextLink URL as opaque.” Its guidance also recommends stable ordering, supplemented with additional sort keys such as a key. Microsoft’s Data API Builder guidance for GraphQL similarly treats the after cursor as opaque and immutable, using endCursor and hasNextPage to drive the next request. These are API-specific contracts, not interchangeable token formats.

Endpoint behavior varies across APIs, including cursor support, filtering and sorting options, and page-size limits. Consult the documentation for the specific endpoint you use rather than assuming one API’s limits apply elsewhere.

Choose based on navigation and workload, then measure

  • Choose offset pagination when direct numbered-page access is a requirement and the workload can tolerate the cost of deeper offsets.
  • Choose cursor/keyset pagination for sequential traversal of large collections, with a unique order and matching indexes.
  • Use a hybrid only when the product genuinely needs both efficient adjacent navigation and direct jumps.
  • For exact point-in-time completeness, define consistency or snapshot behavior separately.
  • Benchmark with the actual database, indexes, query plan, data distribution, and workload. There is no universal speed multiplier that applies to every system.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.