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

Customize

Fill these in and the prompt below updates as you type. Anything you leave blank stays as a placeholder.

Your prompt

5 placeholders left
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

Similar prompts

Design a Database Schema

CREATE TABLE statements with constraints, indexes, and the reasoning behind each choice.

Debug a Performance Problem

Find the N+1s, blocking calls, and hot loops, ranked by impact-per-effort.

Add Diagnostics Before Guessing

Instrument first, theorize second — logging with a stated plan for capturing the failure.

Add Types Incrementally

Type one file with runtime behavior frozen, and make the type-checker output the proof.