Code Room
Code reviewHard
Question
Review this query and the index that was added to 'fix' it.
The `messages` table has 500M rows across ~100k channels.
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.
Learn the concepts
-- hot querySELECT id, bodyFROM messagesWHERE channel_id = 42 AND created_at >= now() - interval '7 days'ORDER BY created_at DESCLIMIT 50; -- the index someone addedCREATE INDEX idx_messages_created ON messages (created_at);Run or narrate your approach, then ask the coach.