SQL Optimizer
Analyze and optimize slow SQL queries with explanations.
What happens when you install it
You run the install command
mcp install-skill sql-optimizerMCPHub CLI downloads this prompt from the registry.
Saved as a file in Claude Code
~/.claude/commands/sql-optimizer.mdClaude Code reads all .md files in this folder as slash commands.
Use it in any conversation
/sql-optimizerin Claude Code (after restart)Claude runs the prompt against your current file or selection — no copy-paste needed.
Content
SQL Optimizer
Analyze and optimize the given SQL query for performance.
Diagnosis
Identify what makes the query slow:
- Full table scans (missing
WHEREindex coverage) - N+1 query patterns
- Correlated subqueries that run per row
- Unnecessary
SELECT * - Missing
JOINindexes - Implicit type conversions blocking index use
ORDER BYon unindexed columns- Large
INlists vs. joins
Output
Problem
Plain explanation of the bottleneck.
Optimized query
-- optimized version with comments explaining key changes
Indexes to add
CREATE INDEX idx_table_column ON table(column);
EXPLAIN analysis
If an EXPLAIN or EXPLAIN ANALYZE output is provided, interpret the key nodes (Seq Scan vs Index Scan, high rows estimates, etc.)
Schema recommendations
Long-term changes to consider (denormalization, partitioning, etc.) — only if clearly worth it.
Note the database engine if it affects the solution (PostgreSQL, MySQL, SQLite behave differently).
Install
After install, restart Claude Code and type:
/sql-optimizerRequires MCPHub CLI
Author

bytebase
github.com/bytebaseSource
bytebase/sql-reviewLooking for Agents?
Agents run with a full system prompt and persistent behavior — not just a one-off command.
Browse agents →