Index Advisor
Installation
SKILL.md
Index Advisor
An index trades write speed and disk for read speed. Add the fewest indexes that serve real query shapes, order their columns deliberately, and prove every change with a plan. The costly mistake is the speculative index: it fails to help the read (wrong column order, predicate too unselective) while permanently taxing every write. This skill owns index design only - plan diagnosis belongs to sql-query-optimizer, and query restructuring belongs to query-rewriter.
Inputs to collect
- The slow query text and its
EXPLAIN (ANALYZE, BUFFERS)output (Postgres) orEXPLAIN ANALYZE/EXPLAIN FORMAT=JSON(MySQL). No plan, no recommendation. - The table's row count and the existing index list (
\d table/SHOW INDEX). - Predicate selectivity: roughly what fraction of rows each WHERE predicate matches. Estimate from
n_distinctinpg_statsor a quickCOUNT(*)ratio; label estimates as guesses. - The write profile: is this table write-hot (high INSERT/UPDATE rate), and which columns get updated?
- For an audit:
pg_stat_user_indexes(or the MySQL equivalent) over a representative window.