Offset vs Cursor Pagination

Offset vs Cursor Pagination

Why page 5,000 is so slow, and how cursors keep every page fast

What you'll learn

  • Why OFFSET gets slower the deeper you go
  • How new and deleted rows cause duplicates and skipped items
  • How cursor pagination works, with a tie-breaker
  • The trade-off: no jumping to page N

In this video, we'll look at why page one of your API loads in 5 milliseconds but page 5,000 is many times slower, and why users scrolling a busy feed see the same items twice. We'll cover how LIMIT and OFFSET work, why deep pages get slower, and how new or deleted rows cause duplicates and skipped items.

We'll also look at cursor (keyset) pagination, how an index lets it jump straight to the next page, and what you give up compared to page numbers.

By the end, you'll know when OFFSET is fine and when a cursor is the better choice for APIs and infinite scroll feeds.

More videos

32 short explainers so far, with more on the way

View all videos

Join the Community

roadmap.sh is among the top 10 most starred projects on GitHub and is visited by hundreds of thousands of developers every month.

Top 10 out of 28M!

371K

GitHub Stars

Star us on GitHub
Help us reach #1

+90kevery month

+3.2M

Registered Users

Register yourself
Commit to your growth

+2kevery month

52K

Discord Members

Join on Discord
Join the community

RoadmapsGuidesFAQsYouTube

roadmap.shby@nilbuild

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

© roadmap.sh·Terms·Privacy·

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.