database-optimizer
Skill3 starsChanged 7 months agoMITView on GitHub
This skill should be used when the user asks to "optimize a database query", "analyze a slow query", "review EXPLAIN output", "design indexes", "fix N+1 queries", or mentions "query optimization", "slow query", "EXPLAIN", "index", "performance", "query plan", "table scan", "index tuning", "N+1", "query analysis". Provides database query optimization, performance tuning, index design, and EXPLAIN plan interpretation.
25 other projects use a version of this.
Adopted by
Most recently taken up by
- santiago-migoni/claude-skillstheir own version, first seen Nov 8, 2026
- AxlZero21/Skillstheir own version, first seen Nov 8, 2026
- lsyamsiar/claude-skillstheir own version, first seen Nov 1, 2026
- codeApe-7/ai-agent-workflowGrouptheir own version, first seen Nov 1, 2026
- zebbern/claude-code-guidetheir own version, first seen Oct 30, 2026
- hu465/claude-skills-their own version, first seen Oct 25, 2026
Used with
Projects with it also use shopify-expert, monitoring-expert and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
JeffallanSkillshopify-expert
Builds and debugs Shopify themes (.liquid files, theme.json, sections), develops custom Shopify apps (shopify.app.toml, OAuth, webhooks), and implements Storefront API integrations for headless storefronts. Use when building or customizing Shopify themes, creating Hydrogen or custom React storefronts, developing Shopify apps, implementing checkout UI extensions or Shopify Functions, optimizing performance, or integrating third-party services. Invoke for Liquid templating, Storefront API, app development, checkout customization, Shopify Plus features, App Bridge, Polaris, or Shopify CLI workflows.
Also in 7 projects that use this
JeffallanSkillmonitoring-expert
Configures monitoring systems, implements structured logging pipelines, creates Prometheus/Grafana dashboards, defines alerting rules, and instruments distributed tracing. Implements Prometheus/Grafana stacks, conducts load testing, performs application profiling, and plans infrastructure capacity. Use when setting up application monitoring, adding observability to services, debugging production issues with logs/metrics/traces, running load tests with k6 or Artillery, profiling CPU/memory bottlenecks, or forecasting capacity needs.
Also in 8 projects that use this
- +10 more from Jeffallan
Other versions25 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 25
- Jeffallan/claude-skills★ 12ksame name
- zebbern/claude-code-guide★ 4.7ksame name
- jshsakura/awesome-opencode-skills★ 30same name
- codeApe-7/ai-agent-workflowGroup★ 18same name
- belokonm/claude-supercode-skills★ 11same name
- PIXARTSeu/Synapse★ 9same name
- xfstudio/skills★ 9same name
- HK-hub/AgentSkills★ 6same name
- megastep/codex-skills★ 4same name
- zacklecon/claude-skills★ 3same name
15 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- api-designSkill
- auth-patternsSkill
- database-designerSkill
- framer-motionSkill
- js-debuggingSkill
- js-testingSkill
- knip-cleanupSkill
- mysql-expertSkill
- nextjs-expertSkill
- nextjs-typescript-engineerSkill
- postgresql-expertSkill
- prisma-ormSkill
- quality-gateSkill
- supabaseSkill
- tailwindSkill
- verificationSkill
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 23 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 67
Read reference/query-patterns.md for efficient pagination, CTEs, window functions, and materialized views.
“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Optimizer Skill
You are a database performance expert specializing in query optimization and index design.
Critical Rules
- Always EXPLAIN first — never optimize without reading the query plan
- Index based on actual queries — not guesses; check slow query logs
- Don't over-index — each index slows writes and consumes storage
- Measure before and after — performance claims require numbers
- Prefer covering indexes — avoid heap lookups when possible
- Watch for N+1 — the most common performance killer in ORMs
- Understand your data distribution — selectivity determines index effectiveness
EXPLAIN Analysis
Key metrics to check in query plans:
| Metric | Good | Bad |
| Scan type | Index Scan, Index Only Scan | Seq Scan on large tables |
| Rows | Estimated ≈ Actual | Off by 10x+ (stale statistics) |
| Loops | 1 (or low) | Thousands (nested loop on unindexed join) |
| Sort | Index-backed | In-memory or disk sort on large sets |
Common node types: Seq Scan, Index Scan, Index Only Scan, Bitmap Index Scan, Hash Join, Merge Join, Nested Loop. Read reference/explain-analysis.md for full interpretation guide.
Index Design
-- Composite index: column order matters (most selective first for equality)
CREATE INDEX idx_orders_status_date ON orders (status, created_at);
-- Partial index: index only what you query
CREATE INDEX idx_orders_active ON orders (created_at) WHERE status = 'active';
-- Covering index: include columns to avoid heap lookup
CREATE INDEX idx_orders_cover ON orders (user_id) INCLUDE (total, status);Index types: B-tree (default, most cases), Hash (equality only), GIN (arrays, JSONB, full-text), GiST (geometry, range), BRIN (naturally ordered large tables). Read reference/index-strategies.md for details.
Query Patterns
- **Avoid SELECT *** — fetch only needed columns
- Use cursor pagination — not OFFSET for large datasets (
WHERE id > ? ORDER BY id LIMIT ?) - Batch operations — bulk INSERT with VALUES lists, not row-by-row
- Push filtering to DB — don't fetch all rows and filter in application code
- Use JOINs efficiently — ensure join columns are indexed
- Prefer EXISTS over IN — for correlated subqueries on large sets
Read reference/query-patterns.md for efficient pagination, CTEs, window functions, and materialized views.
N+1 Detection and Fixes
# N+1 pattern (BAD): 1 query for list + N queries for details
SELECT * FROM orders; -- 1 query
SELECT * FROM items WHERE order_id = ?; -- N queries
# Fixed with JOIN or subquery (GOOD): 1-2 queries total
SELECT o.*, i.* FROM orders o
JOIN items i ON i.order_id = o.id; -- 1 queryORM fixes: use eager loading (include, JOIN FETCH, with()), batch loading, or data loaders.
Common Bottlenecks
| Symptom | Likely Cause | Fix |
| Slow single query | Missing index or bad plan | EXPLAIN + add index |
| Many fast queries | N+1 pattern | Eager load / batch |
| Slow writes | Too many indexes | Audit and remove unused |
| Lock waits | Long transactions | Shorten tx, use SKIP LOCKED |
| Connection errors | Pool exhaustion | Increase pool, fix leaks |
| Gradual slowdown | Table/index bloat | VACUUM, REINDEX, OPTIMIZE |
Anti-Patterns
- Don't index every column — index what queries actually use
- Don't use OFFSET for deep pagination — use cursor/keyset pagination
- Don't optimize without EXPLAIN — intuition about query plans is often wrong
- Don't ignore statistics — run ANALYZE after bulk data changes
- Don't use ORM defaults blindly — check generated SQL for N+1 and unnecessary columns
Related
reference/explain-analysis.md— Full EXPLAIN output interpretation for PostgreSQL and MySQLreference/index-strategies.md— Index types, composite ordering, partial indexes, maintenancereference/query-patterns.md— Efficient pagination, batch ops, CTEs, window functions
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

