Code Room
Code reviewHardcr-g217
Subject Missing indexLevel Senior–Staff~26 minCommon in Databases & SQL interviewsIndustries Software development

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.

Talk through your review
Code to reviewsql
-- 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.