Query Optimization
EXPLAIN PLAN analysis, index selection, join strategies, and slow query debugging.
Install
/plugin marketplace add sethdford/claude-skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add sethdford/claude-skills --skill query-optimizationgit clone --depth 1 https://github.com/sethdford/claude-skills.git /tmp/claude-skills
mkdir -p ~/.claude/skills
cp -r /tmp/claude-skills/engineer/database-engineering/skills/query-optimization ~/.claude/skills/query-optimizationPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Query Optimization Making queries fast through understanding execution plans and indexes. ## Context You are optimizing slow queries. Use EXPLAIN PLAN to understand execution. ## Domain Context - **Execution Plan**: How database executes query; cost is estimate - **Sequential Scan**: Reads all rows; slow on large tables - **Index Scan**: Uses index; much faster if selective - **Join Strategy**: Nested loop, hash, sort-merge; tradeoffs - **Cardinality**: Rows filtered at each step ## Instructions 1. **Identify Slow Queries**: Slow logs, application monitoring 2. **Get EXPLAIN PLAN**: Understand how database executes query 3. **Look for Scans**: Sequential scan on large table = problem 4. **Add Indexes**: On columns in WHERE, JOIN, ORDER BY 5. **Verify Join Order**: Database should join most selective first 6. **Rewrite if Needed**: Sometimes different query is faster 7. **Monitor**: Re-check plan after schema changes ## Anti-Patterns - Optimizing without EXPLAIN PLAN; guessing is unreliable - Adding indexes for every column; slows writes, wastes storage - Not updating stats; optimizer makes bad decisions - Complex queries database can't optimize; rewrite - Indexes on queries that return too much (unconstrained) ## Further Reading - PostgreSQL EXPLAIN documentation - MySQL EXPLAIN documentation - SQL Antipatterns (Joe Celko), Chapter on queries
Details
- Skill name
query-optimization- Repository
- sethdford/claude-skills
- Path
engineer/database-engineering/skills/query-optimization/SKILL.md- License
- MIT
- Repo updated
- 11 March 2026
FAQ
What does the Query Optimization skill do?
EXPLAIN PLAN analysis, index selection, join strategies, and slow query debugging.
How do I install the Query Optimization skill?
Claude Code plugin: /plugin marketplace add sethdford/claude-skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Query Optimization popular?
It lives in sethdford/claude-skills, which has 48 GitHub stars and 10 forks.
Related skills
A B Test Design
48sethdford/claude-skills
Design rigorous A/B tests with hypotheses, variants, metrics, and sample size calculations.
A B Test Design Pm
48sethdford/claude-skills
Analytics and experimentation skill for product managers.
Abuse Case Design
48sethdford/claude-skills
Design abuse cases (negative use cases) showing how attackers misuse system features. Use when identifying attacks that exploit intended functionality or business logic flaws.
Refactoring Catalog
48sethdford/claude-skills
Proven refactoring patterns (Extract Method, Replace Temp, Introduce Parameter Object) to improve code structure safely. Use when improving existing code while keeping behavior unchanged.
Pattern Library
48sethdford/claude-skills
Structure a pattern library entry with problem context, solution pattern, usage examples, and related patterns.
Rest API Design
48sethdford/claude-skills
REST API design with semantic HTTP methods, status codes, and resource modeling. Use when designing new APIs or reviewing existing API designs.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.