Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Diagnose a slow SQL query and produce a concrete optimization plan. Use when asked to optimize SQL, speed up a slow query, reduce a query's cost/scan, fix a timeout, or review a query plan. Produces an analysis — the likely bottleneck, what the plan is doing wrong (full scans, bad joins, spills), the specific rewrite and index/partition changes, and the expected impact, with the optimized query.
.claude/skills/mohitagw15856-sql-optimizer/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 36% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 0% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 40% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 31% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 38% | 0% |
A slow query almost always has a specific, findable cause — a missing index, a non-sargable predicate, a join that explodes rows, a scan that should be a seek. This skill diagnoses it: read what the query (and plan, if given) is actually doing, name the bottleneck, and produce a concrete rewrite plus the index / partition / structural changes — with the expected impact, not vague "add indexes" advice.
Ask for these only if they aren't already provided:
EXPLAIN/query plan, table sizes/row counts, existing indexes, partitioning/clustering.1. What it's doing now — read the query (and plan): the scans, joins, sorts, and where the time/cost goes. Name the primary bottleneck (don't list ten micro-tweaks — find the one that matters).
2. The problems — ranked, each with why it's slow:
SELECT * pulling everything.DISTINCT/GROUP BY on high-cardinality, correlated subqueries that should be joins.3. The fix — the rewritten query, plus the index / partition / clustering / materialization changes. Be specific (CREATE INDEX … ON … (cols), partition on event_date).
4. Expected impact — roughly what each change buys (seek vs. scan, pruning N% of partitions, removing a sort) and how to verify (re-run EXPLAIN, compare bytes/rows).
%)Query-optimization practice — sargability, index/partition pruning, join-order and fan-out, plan reading, columnar bytes-scanned tuning.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 19,320 | 18,997 | -2% | 1 | 1 | 0% | 3,785 | 3,782 | -0% | 0 | 0 | — |
case-02 | fail→pass | 19,146 | 19,970 | +4% | 1 | 1 | 0% | 2,575 | 3,509 | +36% | 0 | 0 | — |
case-03 | pass→pass | 21,890 | 15,101 | -31% | 1 | 1 | 0% | 2,251 | 3,160 | +40% | 0 | 0 | — |
case-04 | pass→pass | 12,918 | 18,941 | +47% | 1 | 1 | 0% | 2,137 | 2,798 | +31% | 0 | 0 | — |
case-05 | pass→pass | 15,919 | 15,136 | -5% | 1 | 1 | 0% | 1,976 | 2,736 | +38% | 0 | 0 | — |
case-06 | pass→pass | 20,408 | 15,870 | -22% | 1 | 1 | 0% | 2,505 | 2,497 | -0% | 0 | 0 | — |
case-07 | pass→pass | 16,739 | 17,883 | +7% | 1 | 1 | 0% | 2,242 | 3,135 | +40% | 0 | 0 | — |
case-08 | pass→pass | 20,738 | 21,148 | +2% | 1 | 1 | 0% | 2,602 | 3,608 | +39% | 0 | 0 | — |
case-09 | pass→pass | 23,204 | 23,008 | -1% | 1 | 1 | 0% | 2,439 | 3,945 | +62% | 0 | 0 | — |
case-10 | pass→pass | 13,731 | 11,507 | -16% | 1 | 1 | 0% | 1,471 | 2,940 | +100% | 0 | 0 | — |
case-11 | pass→pass | 15,158 | 25,717 | +70% | 1 | 1 | 0% | 2,491 | 4,204 | +69% | 0 | 0 | — |
case-12 | pass→pass | 17,307 | 15,136 | -13% | 1 | 1 | 0% | 2,155 | 2,630 | +22% | 0 | 0 | — |
case-13 | pass→pass | 19,408 | 17,744 | -9% | 1 | 1 | 0% | 2,073 | 3,052 | +47% | 0 | 0 | — |
case-14 | pass→pass | 17,437 | 15,305 | -12% | 1 | 1 | 0% | 2,081 | 2,879 | +38% | 0 | 0 | — |
case-15 | pass→pass | 7,978 | 10,202 | +28% | 1 | 1 | 0% | 1,330 | 2,475 | +86% | 0 | 0 | — |
case-16 | pass→pass | 13,430 | 18,900 | +41% | 1 | 1 | 0% | 2,152 | 2,969 | +38% | 0 | 0 | — |
case-17 | pass→pass | 17,622 | 19,033 | +8% | 1 | 1 | 0% | 2,145 | 2,624 | +22% | 0 | 0 | — |
case-18 | pass→pass | 14,747 | 19,094 | +29% | 1 | 1 | 0% | 1,709 | 2,663 | +56% | 0 | 0 | — |
case-19 | pass→pass | 12,161 | 15,444 | +27% | 1 | 1 | 0% | 2,223 | 2,866 | +29% | 0 | 0 | — |
case-20 | pass→pass | 11,058 | 9,739 | -12% | 1 | 1 | 0% | 1,900 | 2,459 | +29% | 0 | 0 | — |
case-21 | pass→pass | 14,748 | 16,271 | +10% | 1 | 1 | 0% | 2,285 | 3,409 | +49% | 0 | 0 | — |
case-22 | pass→pass | 8,902 | 8,280 | -7% | 1 | 1 | 0% | 1,555 | 2,084 | +34% | 0 | 0 | — |
case-23 | pass→pass | 24,373 | 15,956 | -35% | 1 | 1 | 0% | 2,621 | 3,445 | +31% | 0 | 0 | — |
case-24 | pass→pass | 23,082 | 14,478 | -37% | 1 | 1 | 0% | 4,335 | 3,454 | -20% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 24 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.