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 functions, CTEs, indexing strategies, query plan analysis, covering index creation, recursive queries, EXPLAIN/ANALYZE interpretation, before/after query benchmarking, or migrating queries between databas
SQL Pro is a specialized AI skill designed to enhance database query efficiency, optimize schema design, and troubleshoot performance issues. It addresses common challenges in relational databases where queries run slowly or are difficult to maintain, especially when dealing with complex joins, aggregations, or large datasets. By analyzing SQL queries, execution plans, and indexing strategies, this skill helps users identify bottlenecks and implement best practices to achieve faster and more predictable database performance.
The skill offers a structured workflow that starts with schema analysis, evaluating database structures, indexes, and query patterns to pinpoint performance constraints. It then assists in designing queries using advanced techniques such as Common Table Expressions (CTEs), window functions, and appropriate join strategies. Optimization features include execution plan analysis, creation of covering indexes, elimination of full table scans, and iterative refinement to meet performance targets. SQL Pro also emphasizes verification through `EXPLAIN ANALYZE` outputs, ensuring queries run efficiently and indexes are effectively utilized. Comprehensive documentation of queries, index rationale, and performance metrics is provided to support maintainability and knowledge transfer.
SQL Pro is intended for database administrators, developers, and data engineers who work with PostgreSQL, MySQL, SQL Server, or Oracle databases and require expertise in query tuning, schema migration, or performance optimization. Typical use cases include speeding up slow queries, designing normalized schemas, converting queries between database dialects, analyzing execution plans, and implementing complex analytics without sacrificing efficiency. Its guidance is particularly valuable in scenarios requiring advanced SQL features like recursive queries, window functions, and performance benchmarking, making it a key tool for teams aiming to maintain high-performance, scalable database applications.
Provide the query and relevant schema information. SQL Pro will analyze execution plans, suggest index improvements, and rewrite queries using efficient patterns such as CTEs or aggregation joins.
SQL Pro supports PostgreSQL, MySQL, SQL Server, and Oracle, and includes guidance for differences between these dialects.
Yes. It offers guidance for using window functions like ROW_NUMBER, RANK, SUM, and LAG/LEAD efficiently within partitions without unnecessary self-joins.
Key checks include detecting sequential scans on large tables, comparing actual versus estimated row counts, and reviewing buffer hits and reads to identify missing indexes or stale statistics.
Users should have access to database schemas and sufficient privileges to run queries and analyze execution plans. Performance improvements depend on proper indexing, query structure, and database statistics.
Quick Setup:
.claude/skills/Repository
jeffallan/claude-skills