Code Room
On-callMediumoc-g438
Subject Slow queryLevel Mid–Senior~30 minCommon in Databases & SQL interviewsIndustries Technology, Software development

Question

A dashboard query slowed from 200ms to 8s for some users but stayed fast for others, with no deploy. The query filters tasks by `assignee_id` and `status`. `EXPLAIN ANALYZE` on a slow case shows the planner estimating ~50 rows but actually returning ~900k — it chose an index nested loop that's terrible at that real volume. The `status` column is wildly skewed: 95% of all rows are `status='done'`, and the slow users are ones querying their large pile of done tasks. Stats are up to date. Triage and mitigate.

What a strong answer looks like

Stop the bleeding first (mitigate), then form hypotheses from real signals. Separate root cause from symptom, communicate status as you go, and close with what prevents a repeat.

Diagram & narrate the incident
Loading whiteboard…
Run or narrate your approach, then ask the coach.