database-optimization
Query optimization, indexing strategies, and database performance tuning for PostgreSQL and MySQL
npx skills add rohitg00/awesome-claude-code-toolkit --skill database-optimization --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Database Optimization ## EXPLAIN Analysis Always run `EXPLAIN ANALYZE` before optimizing. Read the output bottom-up. ```sql -- PostgreSQL EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT ...; -- MySQL EXPLAIN ANALYZE SELECT ...; ``` Key metrics to watch: - **Seq Scan** on large tables = missing index - **Nested Loop** with high row count = consider hash/merge join - **Sort** without index = add index on sort column - **Rows estimated vs actual** divergence = stale statistics, run `ANALYZE` ## Index Strategies ### B-tree (default, most cases) ```sql CREATE INDEX idx_users_email ON users (email); CREATE INDEX idx_orders_user_date ON orders (user_id, created_at DESC); ``` Use for: equality, range queries, sorting. Column order matters in composite indexes: put equality columns first, then range/sort columns. ### Partial Index (PostgreSQL) ```sql CREATE INDEX idx_orders_pending ON orders (created_at) WHERE status = 'pending'; ``` Use when queries always filter on a specific condition. Dramatically smaller than full indexes. ### GIN (PostgreSQL - arrays, JSONB, full-text) ```sql CREATE INDEX idx_products_tags ON products USING GIN (tags); CREATE INDEX idx_docs_search ON documents USING
- EXPLAIN Analysis
- Index Strategies
- B-tree (default, most cases)
- Partial Index (PostgreSQL)
- GIN (PostgreSQL - arrays, JSONB, full-text)
- GiST (PostgreSQL - spatial, range types)
- Covering Index (index-only scans)
- N+1 Query Detection
- Connection Pooling
- Read Replicas
- Partition Strategies
- Range Partitioning (time-series data)
- Hash Partitioning (even distribution)
- Query Optimization Checklist
What does the database-optimization skill do?
Query optimization, indexing strategies, and database performance tuning for PostgreSQL and MySQL
How do I install it?
Run `npx skills add rohitg00/awesome-claude-code-toolkit --skill database-optimization --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From rohitg00/awesome-claude-code-toolkit, a repository with 2,438 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.