Data & SQL21 categories
Read this query plan with me
You have an EXPLAIN output and no idea which line is the problem.
Walk me through this query plan. 1. Identify the operation consuming the most actual time, not the highest estimated cost. 2. Point out every place where the estimated row count differs sharply from the actual. Say what causes each mismatch: stale statistics, correlated predicates, a function the planner cannot estimate. 3. Name the join strategies chosen and say whether each makes sense at these row counts. Flag any nested loop over a large outer set. 4. Identify spills to disk, external sorts, and anything re-executed per row. 5. Translate the top problem into plain language: what is the database actually doing too much of? Then give me the single highest-impact change, and say what the plan should look like afterwards so I can confirm it worked. Query: Plan:
Making it yours
- Paste your own material where the prompt asks for it. Everything above that line is instruction, not content.
- Delete any rule that does not apply to you. A shorter prompt that fits beats a thorough one that does not.
- If the answer comes back vague, add a line saying what you do not want. Constraints work better than encouragement.
Making queries faster. Diagnosing a slow query, reading the plan, and finding the smallest index that fixes it.
Related prompts
Make this slow query fasterA query that used to be fine now takes minutes.What index should this query have?A query does a sequential scan and you want the smallest index that fixes it.Why is this query slow?A query got sluggish and you want one lead, not a checklist.Will this query use my index?You added an index and the plan still shows a sequential scan.Explain this query to me line by lineYou inherited a 200-line query and need to understand it before changing it.Write the query from a plain-language questionYou know exactly what you want to know and not how to express it in SQL.
Keep this one
Phrasery saves prompts with a right-click and puts them back the same way. Add this to your own library in one click.
Add to your browser โ free