database-optimizer · qdhenry — Claude Code subagent for database tuning
database-optimizer — a subagent for database performance analysis: finds bottlenecks in SQL queries, indexing, schema design and infrastructure.
no license ★ 1,357 updated 2026-03-01
.claude/agents/database-optimizer.mdWhat database-optimizer does
The subagent dissects slow queries with EXPLAIN ANALYZE, suggests indexes tailored to specific query patterns, and refines schemas through normalization or strategic denormalization. It spots N+1 queries, locking conflicts, and points out where to add caching layers like Redis.
Inside: file read/write, grep, bash, web search, and MCP servers context7 (DBMS docs and optimization patterns) and sequential-thinking (step-by-step migration planning). Supports PostgreSQL, MySQL, MongoDB.
Before each recommendation it asks for the DBMS and table schemas. Never modifies data directly: outputs ready-to-run scripts for manual execution.
What it helps with
- rewrite a slow SQL query after profiling it
- design indexes for frequent filter patterns
- detect N+1 queries in ORM code
- plan zero-downtime schema migrations
- add caching for expensive analytical queries
Example prompts for the agent
- Profile the query in
queries/reports.sqlwithEXPLAIN ANALYZEand show where it slows down - Suggest indexes for the
orderstable to speed up filtering by status and date - Find all places in the codebase where the ORM makes N+1 queries to
users
How to install database-optimizer
Manually: put the files in place
.claude/agents/database-optimizer.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/database-optimizer.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/database-optimizer.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about database-optimizer
How to install database-optimizer in Claude Code?
Place the subagent file at .claude/agents/database-optimizer.md.
What does database-optimizer do?
Analyzes database performance: profiles query execution plans, recommends indexes, cleans up schemas, and plans migrations. Does not modify data itself — outputs scripts for manual execution.
Which databases does database-optimizer support?
PostgreSQL, MySQL and MongoDB. Asks which DBMS you use before starting, to provide accurate syntax.
Similar subagents
All subagents for Data and databases →database-optimizer by other authors comes first.