sql-pro

Optimizes SQL queries, designs database schemas, and troubleshoots performance issues. Use when a user asks why their query is slow, needs help writing complex joins or aggregations, mentions database performance issues, or wants to design or migrate a schema. Invoke for complex queries, window func

By jeffallan · 5,631 installs

npx skills add jeffallan/claude-skills --skill sql-pro

Source repository · Upstream listing

SQL Pro Core Workflow 1. Schema Analysis Review database structure, indexes, query patterns, performance bottlenecks 2. Design Create set based operations using CTEs, window functions, appropriate joins 3. Optimize Analyze execution plans, implement covering indexes, eliminate table scans 4. Verify Run EXPLAIN ANALYZE and confirm no sequential scans on large tables; if query does not meet sub 100ms target, iterate on index selection or query rewrite before proceeding 5. Document Provide query explanations, index rationale, performance metrics Reference Guide Load detailed guidance based on context: Topic Reference Load When Query Patterns references/query patterns.md JOINs, CTEs, subqueries, recursive queries Window Functions references/window functions.md ROW NUMBER, RANK, LAG/LEAD, analytics Optimization references/optimization.md EXPLAIN plans, indexes, statistics, tuning Database Design references/database design.md Normalization, keys, constraints, schemas Dialect Differences references/dialect differences.md PostgreSQL vs MySQL vs SQL Server specifics Quick Reference Examples CTE Pattern Window Function Pattern EXPLAIN ANALYZE Interpretation Key things to check in the output: Seq Scan on large table → add or fix an index actual rows ≫ estimated rows → run ANALYZE <table to refresh statistics Buffers: shared hit vs read → high read count signals missing cache / index Before / After Optimization Example Constraints MUST DO Analyze execution plans before recommending optimizations Use set based operations over row by row processing Apply filtering early in query execution (before joins where possible) Use EXISTS over COUNT for existence checks Handle NULLs explicitly in comparisons and aggregations Create covering indexes for frequent queries Test with production scale data volumes MUST NOT DO Use SELECT in production queries Use cursors when set based operations work Ignore platform specific optimizations when targeting a specific dialect Implement solutions without considering data volume and cardinality Output Templates When implementing SQL solutions, provide: 1. Optimized query with inline comments 2. Required indexes with rationale 3. Execution plan analysis 4. Performance metrics (before/after) 5. Platform specific notes if applicable [Documentation](https://jeffallan.github.io/claude skills/skills/language/sql pro/)