Optimize a Slow Query
Read the execution plan, name the real bottleneck, and get a rewrite plus the exact index to add.
Advanced1 min read
- Languages
- SQL
Customize
Fill these in and the prompt below updates as you type. Anything you leave blank stays as a placeholder.
The exact query to run or optimize
Which engine this runs on
The result to walk through, step by step
Roughly how many rows in the tables involved
The database indexes already in place
Your prompt
This query is slow. Diagnose why and propose faster alternatives. Query: {{query}} Database: {{database}} EXPLAIN / execution plan: {{explain_output}} Relevant tables and row counts: {{table_sizes}} Existing indexes: {{indexes}} Give: 1. The root bottleneck (full scan, bad join order, missing index) 2. A rewritten query 3. Any index to add (with the exact CREATE INDEX) 4. The tradeoff of that index on writes