Back to Blog
PaginationAPIDatabasePerformance

Pagination Patterns: Efficiently Loading Large Datasets

Implement pagination for APIs and UIs. Learn offset, cursor, and keyset pagination with performance considerations.

B
Bootspring Team
Engineering
February 27, 2026
6 min read

Pagination prevents loading entire datasets at once. This guide covers pagination strategies with their tradeoffs.

Offset Pagination#

Simple but has performance issues at scale:

Loading code block...
Loading code block...

When to Use#

  • Small datasets (< 10,000 rows)
  • Need to jump to specific pages
  • Simple UI requirements

Cursor-Based Pagination#

Better performance for large datasets:

Loading code block...

Encoding Cursors#

Loading code block...

Bidirectional Cursor Pagination#

Loading code block...

Keyset Pagination#

Most efficient for sorted data:

Loading code block...
Loading code block...

GraphQL Pagination (Relay Style)#

Loading code block...
Loading code block...

Frontend Implementation#

React with Infinite Scroll#

Loading code block...

Comparison#

MethodPerformanceJump to PageConsistency
OffsetPoor at scaleYesInconsistent
CursorGoodNoConsistent
KeysetExcellentNoConsistent

Conclusion#

Use offset pagination for simple cases with small datasets. Switch to cursor or keyset pagination for large datasets or real-time data. Cursor pagination provides the best balance of performance and usability for most applications.

Share this article

Help spread the word about Bootspring

Related articles