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

Question

A search endpoint that filters customers by a phone-number field started timing out after a deploy that 'just changed a query.' `EXPLAIN ANALYZE` shows a sequential scan over the 50M-row `customers` table even though there's a btree index on `phone`. The column is `varchar` but the new code passes the parameter as an integer (`bigint`). Older queries on the same column are still fast and use the index. CPU climbs whenever the endpoint is hit. 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.