fixaiprompt
All templates
💻 Coding·Works on: claude, chatgpt, cursor

SQL Query Optimizer

Make a slow query fast — with the reasoning shown.

#sql#database#performance
0/5
Fill the template
5 placeholders left.
Live preview
Act as a database engineer. Optimize this query.

Query:
```sql

```

DB engine + version: 
Table size (approx rows): 
Current execution time: 
What the query is supposed to return: 

Deliver:
1. The optimized query.
2. A bullet list of EVERY change you made, with one-line reason each.
3. Any indexes I should add (CREATE INDEX statements).
4. The expected complexity / cost change (e.g. "seq scan → index scan, O(N) → O(log N)").
5. Anything that depends on assumptions you can't verify — list those explicitly.
Inputs0 of 5
e.g. Postgres 15
e.g. users ~50M, orders ~200M
See the lazy version this template replaces
Before — the lazy prompt
optimize this SQL:
<paste>

Why it works

  • Schema and engine info change the right answer drastically — required up front.
  • Per-change reasoning lets you spot a wrong assumption fast.
  • Index CREATE statements are the highest-leverage line in the answer.

Make this one yours

Replace the bracketed placeholders, then paste into the Prompt Fixer to lint your customisation before hitting send.