Audit intermediate Works with: Any AI

Slow Query Triage: What to Check Before You Add an Index

Table output

Work through causes of a slow query in a sensible order.

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

[VERIFY] is an editorial flag, not a blank to fill. Wherever the prompt shows [VERIFY], check that item against a reliable source before you use it.

Rate this prompt

Loading ratingsโ€ฆ

Triage a slow SQL query. The query: [SQL_QUERY]. The database system and version: [DATABASE_SYSTEM]. Table sizes: [TABLE_SIZES]. Existing indexes: [INDEXES]. The execution plan or timing output if available: [EXECUTION_PLAN].

Work through these checks in order and for each state what I should look at and what the result would mean: is the query returning more rows or columns than needed; are there functions on filtered columns; do join conditions match indexed columns and types; are statistics up to date [VERIFY]; is the plan using scans where it should use seeks; are there large sorts or aggregates; is the query run too often. Make a table with Check, Finding from my information, Suggested change, and Risk. Propose one change at a time with a way to measure before and after. Mention the costs of adding an index (write overhead, storage).

Do not recommend changes to production systems without testing in a safe environment.

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