Code RoomOffset pagination performance cliff
HardPrep Room Coding #1848

Offset pagination performance cliff

Code reviewDatabases & SQLNetworking & APIsSenior–Staff~26 min

Review this SQL-backed feed pagination (page is 1-based, page_size = 50). The query is regenerated per request; `$1` = feed_id, `$2` = page number from the client.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 26 min
Mark a line and say what kind of problem it is.0 findings
1-- ordered by recency; an index exists on posts(feed_id, created)
2SELECT p.id,
3 p.body,
4 p.created,
5 u.handle AS author
6FROM posts p
7JOIN users u ON u.id = p.author_id
8WHERE p.feed_id = $1
9 AND p.deleted_at IS NULL
10ORDER BY p.created DESC
11LIMIT 50
12OFFSET ($2 - 1) * 50;
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.