SQL Query Optimizer
Description
Analyzes and optimizes SQL queries for better performance. Suggests indexes, rewrites queries, and explains execution plans.
Code
Skill Code
Optimization includes: 1. Query analysis 2. Index recommendations 3. Query rewriting 4. Subquery elimination 5. JOIN optimization 6. Execution plan explanation
Usage Examples
Examples
User: optimize this slow query Claude: *analyzes query* **Current query issues:** 1. Full table scan on `orders` (missing index) 2. Subquery can be converted to JOIN 3. SELECT * fetches unnecessary columns **Optimized query:** ```sql SELECT o.id, o.total, c.name FROM orders o INNER JOIN customers c ON o.customer_id = c.id WHERE o.created_at >= '2025-01-01' AND o.status = 'completed'; -- Add index: CREATE INDEX idx_orders_created_status ON orders(created_at, status); ``` **Expected improvement:** ~95% faster
Installation
Add the following to your CLAUDE.md file (project root or ~/.claude/CLAUDE.md for global):
CLAUDE.md
# SQL Query Optimizer Optimization includes: 1. Query analysis 2. Index recommendations 3. Query rewriting 4. Subquery elimination 5. JOIN optimization 6. Execution plan explanation
Comments (0)
No comments yet. Be the first to share your thoughts!
Leave a Comment