System Design · Middle · Question 2 of 75
Why is cursor pagination better than offset pagination for a feed?
- ✓Correct answer: No duplicates on inserts and fast on deep pages
- 2It lets you jump straight to any page by its number
- 3It doesn't require sorting data on the server
Explanation
With offset, new posts shift the window and the user sees repeats; OFFSET 100000 is expensive for the DB. A cursor ("after the record with id X") is stable and efficient on an index. The downside is you can't jump to page 57, so for tables with page numbers offset is sometimes more appropriate.