pythia-tunelisted
Install: claude install-skill thaildhe172591/pythia
# Tuning a Query or a Unit
**Announce at start:** "Using pythia-tune — measuring before changing anything."
**Phase:** Learn → Ask → Do — the plan and the statistics first, one proposed change, the same measurement after
Performance folklore is the most confident kind of wrong. "Add an index",
"use a hint", "rewrite it as a join" — each is right for some plans and
harmful for others, and only the plan says which. Tuning without a before
and after is guessing with extra steps.
## The Iron Law
```
NO TUNING CHANGE WITHOUT A MEASUREMENT BEFORE AND THE SAME ONE AFTER
```
## The Workflow
1. **Get the real statement.** The exact SQL the application runs — from
`pythia src` / `pythia grep`, with its bind variables as binds (`:id`),
not pasted literals: a literal can get a different plan than the bind.
2. **Measure.**
- `pythia explain "<the select>"` — the optimizer's plan; read rows
(cardinality), cost, the access path per table, and the `-- note:`
lines pythia adds (full scans, Cartesian joins, implicit conversions,
dynamic sampling).
- `pythia stats <TABLE>` for each table in the plan — row counts, when
statistics were gathered, STALE, the indexes and their columns,
unindexed foreign keys.
- For DML, explain the `SELECT` that finds its rows.
3. **Diagnose with the checklist** (`reference/tuning-checklist.md`), in
order — cheapest and most common causes first: statistics, a predicate
that cannot use an index, the wrong or missin