Slow SQL Query Explainer

coding · Claude Code · free

This query is slow. Explain the plan and tell me exactly where the time goes. The query: EXPLAIN (ANALYZE, BUFFERS) output (Postgres) or equivalent: Schema + row counts of touched tables: [PASTE] DB engine + version: [Postgres X / MySQL X] Server class: [CPU / RAM / DISK TYPE] Walk me through: 1. Read the plan from the innermost node out — which node is the actual hotspot (highest actual time × loops) 2. Where the row estimate diverges from reality by 10x — stats out of date, correlation, missing extended stats 3. Which scan node is doing the wrong thing (Seq Scan on a filterable large table? Index Scan on a low selectivity index?) 4. Sorts and hashes hitting disk — the Sort Method: external merge smell 5. Join order — is the planner joining the largest tables first because it's wrong about cardinality? 6. What CHANGES to make, ranked by expected impact: Analyze / vacuum Add / drop an index Rewrite the query (denormalize a filter, avoid OR, split into a UNION) Materialized view or a summary table…

#sql #performance #debugging