awesome-everything RU
↑ Back to the climb

APIs

Pagination: free-recall review

Crux Free-recall prompts across the pagination unit. Answer each in your own words first, then reveal the model answer and compare.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 14 min

Retrieval beats re-reading. For each prompt, say or write a full answer from memory before you open the model answer — the effort of recall is what makes the mechanism stick.

Goal

Reconstruct the unit’s core mechanisms — why offset scales with depth, why it drifts, what makes a keyset key valid, why cursors are opaque, and why exact counts are expensive — without looking back at the lesson.

Recall before you leave
  1. 01
    Why does LIMIT 20 OFFSET 200000 get slower the deeper you page, even though it always returns 20 rows?
  2. 02
    Explain result drift: why does an offset feed show duplicate and missing items, and why even on a small table?
  3. 03
    What two properties must a keyset sort key have, and what breaks if the key is not unique?
  4. 04
    Why expose an opaque cursor instead of the raw (created_at, id) keys, and what does the client do with it?
  5. 05
    What does keyset give up compared to offset, and when is offset still the right choice?
  6. 06
    Why is an exact total count expensive in Postgres, and what are the alternatives in order of preference?
Recap

If you reconstructed each answer from memory, you hold the unit’s spine: offset cost scales with depth because the engine reads and discards every prior row; offset drifts because position is not a stable address under writes; a valid keyset key is unique, stable, and index-backed, compared as a whole tuple; the cursor is opaque so the contract can evolve and clients can’t craft expensive seeks; keyset trades arbitrary page jumps for flat latency, which is why offset still fits bounded admin surfaces; and an exact count is an MVCC full scan, so estimate or probe with n+1 instead.

Continue the climb ↑Pagination: SQL and code reading
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.