From aj-geddes-useful-ai-prompts-4
Analyzes and optimizes SQL queries for performance in PostgreSQL and MySQL. Use when improving slow queries, reducing execution time, or analyzing query plans.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:sql-query-optimizationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Analyze SQL queries to identify performance bottlenecks and implement optimization techniques. Includes query analysis, indexing strategies, and rewriting patterns for improved performance.
PostgreSQL:
-- Analyze query plan with execution time
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
SELECT u.id, u.email, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at > NOW() - INTERVAL '1 year'
GROUP BY u.id, u.email;
-- Check table statistics
SELECT * FROM pg_stats
WHERE tablename = 'users' AND attname = 'created_at';
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Analyze Current Performance | Analyze Current Performance |
| Common Optimization Patterns | Common Optimization Patterns |
| Query Rewriting Techniques | Query Rewriting Techniques |
| Batch Operations | Batch Operations |
npx claudepluginhub aj-geddes/useful-ai-promptsOptimizes SQL queries using indexing strategies, EXPLAIN plan analysis, and systematic tuning. Use when debugging slow queries, designing schemas, or improving database performance.
Optimizes SQL queries, indexing strategies, and database performance across MySQL, PostgreSQL, SQL Server, and Oracle. Analyzes execution plans, pagination, batch operations, and more.
Optimize SQL queries with indexing strategies and EXPLAIN analysis to improve database performance. Use when debugging slow queries or designing schemas.