Join our Newsletter — 33% off our NHI Course
Home› FAQ› Foundations & NHI Taxonomy› Why do keyset pagers need a tie breaker?
Foundations & NHI Taxonomy

Why do keyset pagers need a tie breaker?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated November 25, 2026 Domain: Foundations & NHI Taxonomy

A tie breaker ensures rows with the same sort key still page in a stable, repeatable order. Without a second ordering column, keyset pagination can skip or duplicate records when values such as timestamps are not unique. Teams usually add a unique column, such as an ID, to the ORDER BY and the cursor predicate.

What a tie breaker does in keyset pagination

A keyset pager needs a tie breaker when the leading sort column is not guaranteed to be unique. The second ordering column gives the database a deterministic way to decide which row comes next, so the cursor advances consistently instead of relying on an ambiguous sort boundary.

In practice, the tie breaker is usually a unique column such as the primary key. That lets the query express a strict “greater than” or “less than” condition across the full ordering, which is what makes keyset paging stable under repeated reads.

Why non-unique sort keys break pagination

Without a tie breaker, rows that share the same sort value can sit on either side of a page boundary depending on how the engine resolves ties. That creates two common problems: the same record can appear twice across adjacent pages, or a record can be skipped entirely when the cursor resumes from an ambiguous value.

The issue is most visible with timestamps, scores, or status fields because those values often repeat. A stable pagination cursor has to identify a single, ordered position, not just a coarse bucket of rows. A unique secondary column turns a loose ordering into a precise traversal path.

How to design a reliable cursor order

The safest pattern is to order by the business sort key first and a unique column second, then carry both values in the paging cursor. For ascending order, the next page should request rows that are greater than the last seen pair, not merely greater than the last timestamp or other shared value.

That design keeps page transitions repeatable even while new rows are inserted. It also makes result order easier to reason about during debugging, because each page boundary is anchored to a specific row rather than a non-unique value that may match many rows.

Practitioner Guidance

What to verify: Confirm that the ORDER BY clause produces a total ordering, not just a logical grouping. If the leading sort column can repeat, add a unique tie breaker and make sure the cursor predicate uses the same composite order in both directions.

Common mistake: Teams often sort by a timestamp alone and assume the database will preserve a stable sequence. That works until two rows share the same timestamp, at which point page boundaries become ambiguous and pagination results drift.

Practitioner takeaway: Keyset pagination is only as stable as its ordering, so the tie breaker is not optional metadata, it is the part that makes the cursor unambiguous.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org