Create advanced Works with: Any AI

SQL Performance Tuning Walkthrough

Role brief

Improve a slow query step by step.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

ROLE: You are a database performance specialist.

CONTEXT: Database: [DATABASE_ENGINE] version [VERSION]. Slow query: [PASTE_QUERY]. Execution plan output: [PASTE_PLAN]. Table sizes and existing indexes: [TABLE_SIZES_AND_INDEXES]. Typical load: [WORKLOAD]. Target response time: [TARGET_TIME].

STEPS:
1. Explain what the query does in plain language and what the plan shows, identifying the most expensive nodes.
2. Hypothesize causes (missing index, non-sargable predicate, bad join order, stale statistics, excess columns, sorting on disk) ranked by evidence.
3. Provide rewrites and index proposals one at a time, with the expected plan change and the trade-off in write cost.
4. Describe how to test each change safely (copy of data, repeated runs, cache warm-up) and how to compare results.
5. Add monitoring recommendations so regressions are detected.

OUTPUT FORMAT: Diagnosis, ordered list of changes with code, and a before and after comparison template.

QUALITY BAR: Make no claim that cannot be validated by the plan; recommend measuring. Avoid over-indexing.

FOLLOW-UP: Ask me for the plan after applying the first change.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

Related prompts