Code Room
Code reviewHard
Question
Review this SQL. The index exists but EXPLAIN still shows a sort + filter, and the query is slow.
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
-- existing index:CREATE INDEX idx_app ON applications (status, created); -- the slow query:SELECT id, candidate_id, createdFROM applicationsWHERE company_id = $1 AND status = 'submitted'ORDER BY created DESCLIMIT 20;Run or narrate your approach, then ask the coach.