Diagnose Why a Specific Query Got Slow as a Table Grew
Tap any variable to replace it with your own value:
AI prompt
Act as a database performance engineer diagnosing why a specific query has gotten slow as a table grew. Database: [Postgres/MySQL/etc.]. The query: [paste the actual SQL]. Table size now vs. when it was fast: [e.g. '50M rows now, was fine under 500K']. I'll paste the query plan if I have one: [paste EXPLAIN ANALYZE output, or say 'no plan available']. Produce: (1) the most likely cause given the query shape and the growth pattern (a missing index, a sequential scan that used to be cheap and now isn't, an N+1 pattern, a join exploding row counts) stated as a specific diagnosis, not a generic checklist; (2) the exact index or query rewrite that would fix it, written out, not just described; (3) how to verify the fix actually worked (what to check in the query plan before and after); (4) whether this fix is safe to apply directly on a live production table or needs a maintenance window, and why.
Related prompts
- Audit Your Database Indexes Against How the App Actually Queries It
Check whether your current indexes match the slow query patterns.
- Turn a vague performance complaint into a specific bottleneck to fix
Pin down whether the slowdown is really in the database first.
- Get a senior-engineer critique of your database schema before you commit to it
Prevent the same scaling problem by fixing weak schema choices early.
- Debugging strategy framework for a bug
Work through a broader debugging plan when the query is only one suspect.
- Catch performance bottlenecks in code before they hit production
Catch N plus 1s and expensive code paths behind the query load.