Bird
Raised Fist0

You have this SQL snippet for keyset pagination:

medium📝 Debug Q6 of Q15
Rest API - Pagination Patterns
You have this SQL snippet for keyset pagination:
SELECT * FROM users WHERE id >= :last_id ORDER BY id ASC LIMIT 10;

What is the main problem with this query?
AIt orders results in descending order
BIt may return the last record twice on consecutive pages
CIt does not limit the number of rows
DIt will skip the first record after last_id
Step-by-Step Solution
Solution:
  1. Step 1: Analyze WHERE condition

    Using >= means the row with id equal to last_id is included again.
  2. Step 2: Understand pagination effect

    This causes the last record of previous page to appear again on next page, duplicating results.
  3. Final Answer:

    It may return the last record twice on consecutive pages -> Option B
  4. Quick Check:

    Duplicate record risk = D [OK]
Quick Trick: Use > not >= to avoid duplicate last record [OK]
Common Mistakes:
MISTAKES
  • Using >= instead of > in WHERE clause
  • Ignoring duplicate records on page boundaries
  • Assuming LIMIT controls duplicates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes