Skip to main content
InterviewHubPRO
Section Overview
Q31

Question 31 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

62%
SQL & Relational Databases (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

How do you optimize Deep Pagination (`OFFSET 1000000 LIMIT 10`)?

senior Levelsql-databasesAdvanced Internals

In Simple Words: Traditional OFFSET scans and discards $1,000,000$ rows:

  • Keyset Pagination (Seek Method): WHERE id > :last_seen_id ORDER BY id ASC LIMIT 10; Executes in $O(1)$ constant time regardless of how deep the user paginates.