Layer 3 · Go deeper · 6 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Build-up · 4 steps
Watch OFFSET show an order twice
A restaurant’s order dashboard at dinner rush, three orders a page, newest first. One insert lands between two page requests.
Step 1 of 4
Page 1, at t1
OFFSET 0 returns the three newest orders, O9, O8 and O7.
4 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 4
Interviewer
“Your public order-history API pages with ?page=N. Scrapers walk every page and the database groans. What do you do?”
Your move. Pick an approach:
Deep dive 2 of 4
Interviewer
“A “biggest orders first” list sorts total_paise DESC, id ASC. A teammate writes the cursor as (total_paise, id) < ($1, $2). Ship it?”
Your move. Pick an approach:
Deep dive 3 of 4
Interviewer
“Orders are sharded 16 ways, and the list isn’t filtered by the shard key. How do you page it?”
Your move. Pick an approach:
Deep dive 4 of 4
Interviewer
“Product wants “Page 3 of 48,213” on an order list that will reach 200 million rows. What do you offer?”
Your move. Pick an approach:
Build-up · 4 steps
Next and previous with two cursors
Three rows a page. Rows 15, 14 and 13 are on screen, newest on the left. Each response carries the keys of its first and last rows.
Step 1 of 4
Two cursors on screen
The first row’s key drives Previous and the last row’s key drives Next. The same index on (ts, id) serves both directions.