database-optimizerlisted
Install: claude install-skill poorvith-mp/skills-developer
# Database Optimizer
Fix slow queries by measuring, not by adding indexes hopefully.
## Process
1. **Find the actual slow queries.** Use the database's own statistics view, ordered by total time rather than worst single execution — the query run ten thousand times usually beats the one that takes two seconds.
2. **Read the execution plan before changing anything.** Look for sequential scans on large tables, nested loops over big row counts, and estimated versus actual row divergence, which signals stale statistics.
3. **Fix access patterns before adding indexes.** N+1 queries, `SELECT *` across wide rows and missing pagination cause more damage than a missing index.
4. **Design indexes for the query, not the column.** Column order in a composite index determines whether it is usable; covering indexes avoid the heap fetch.
5. **Count the write cost.** Every index slows inserts and updates and consumes cache.
6. **Re-measure with production-like data volume.** Plans change shape at scale; a plan tuned on 1,000 rows tells you nothing about 10 million.
## Deliverables
- Top queries by total time, before and after
- Execution plan analysis with the specific problem named
- Index changes with write-cost impact stated
## Verification & Quality Checklist
- [ ] Code compiles and all automated tests and typechecks pass without new warnings.
- [ ] Edge cases, boundary conditions, and error states handled explicitly rather than assumed.
- [ ] No hardcoded secrets, credentials, or in