Command
Add Index
Proposes an index for one slow query with plan evidence and the write cost, then creates it safely only when you approve.
11. Read the query, the table definition and every existing index on the table. Note row counts if known.
22. Get the plan with `EXPLAIN` (read-only connection, never `EXPLAIN ANALYZE` on a write). If no database is reachable, reason from the schema and say the plan is predicted.
33. Choose the index: equality columns first, then range or sort columns; add INCLUDE or a partial WHERE only when it clearly pays. Check whether an existing index can be extended instead of adding a new one.
44. State the evidence (scan type, rows, cost) and the price: extra disk, write overhead on INSERT and UPDATE, and which other queries it also helps.
55. Write the migration in the project's tool with a non-blocking build (`CREATE INDEX CONCURRENTLY` on Postgres) and a drop in the down step.
Claude CodeCodex
Add Index
CommandDatabases
Free