Skip to main content
subagent

database-optimization — Claude Code subagent: what it does

A subagent for slow queries: reads execution plans, suggests indexes and connection pool settings.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --agent database/database-optimization
Open on GitHub

What database-optimization does

The database-optimization subagent handles database performance work: execution plan analysis, indexing, connection pooling, transactions, schema design. It runs with Read, Write, Edit and Bash, so it can fire off EXPLAIN ANALYZE itself and edit your SQL files.

The workflow is measure first, optimize second. It won't guess from source code alone — it asks for real numbers and builds indexes from actual query patterns. You get rewritten queries with plan comparisons, index recommendations with impact estimates, connection pool configs, and monitoring queries. PostgreSQL and MySQL get engine-specific treatment.

Worth reaching for when a query suddenly crawls and the cause isn't obvious. Without access to a live database or at least its statistics, though, there's little to work with: the subagent needs real execution plans, not guesses. Behind a proxy or private mirror, set that up in your environment or the tool's config file rather than on the install line.

What it helps with

  • trace a slow query back through its execution plan
  • pick indexes that match real query patterns
  • compare plans before and after rewriting SQL
  • size a connection pool for the workload
  • review schema design and plan migrations

Example prompts for the agent

  • Dig into this slow query: pull the execution plan and tell me what to rewrite
  • Check the indexes on the orders table and tell me which ones are missing
  • Compare the execution plan before and after my query change

How to install database-optimization

1claude-code-templates

npx claude-code-templates@latest --agent database/database-optimization

2Manually: put the files in place

.claude/agents/database-optimization.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about database-optimization

How do I install database-optimization in Claude?

Through the templates CLI: npx claude-code-templates@latest --agent database/database-optimization. The subagent file then lives at .claude/agents/database-optimization.md.

What does database-optimization do?

It analyzes query execution plans, recommends indexes, tunes connection pooling and transactions, and suggests schema changes with migration paths.

Which tools can the subagent use?

Read, Write, Edit and Bash. The Bash tool is how it runs EXPLAIN ANALYZE against your database.

Similar subagents

All subagents for Data and databases →

From the same set205

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor