Search timeout with type mismatch
Your task
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.
It covers
- Statement timeout
- Missing index
- Type mismatch