SQL Pro gives the agent a workflow for slow queries and schema design: review the schema and query patterns, design set-based queries, analyze execution plans, add covering indexes and verify the result with EXPLAIN ANALYZE before documenting it.
The skill includes examples for a CTE with ROW_NUMBER, window function running totals, EXPLAIN ANALYZE interpretation and a before-and-after rewrite of a correlated subquery with a supporting covering index.
What You Get
- A five-step workflow that ends with EXPLAIN ANALYZE verification
- Examples for CTEs, window functions, EXPLAIN ANALYZE reading and a before-and-after optimization
- Guidance on what to check in a plan: sequential scans, estimate gaps and buffer reads
- A must-do list covering early filtering, EXISTS over COUNT, explicit NULL handling and covering indexes
- An output layout with the optimized query, index rationale, plan analysis and before-and-after metrics
- Reference files for query patterns, window functions, optimization, database design and dialect differences
Common Use Cases
- Finding out why a query is slow and rewriting it
- Writing ranking, running total and latest-row-per-group queries
- Designing indexes for frequent queries
- Moving queries between PostgreSQL, MySQL, SQL Server and Oracle
What Makes It Unique
The skill requires evidence before advice: the agent analyzes execution plans before recommending changes and reports before-and-after performance numbers. It covers four database dialects in one skill and has a reference for the differences between them.
Under The Hood
The skill is a SKILL.md with five reference files that the agent loads by topic. It ships no scripts. The examples are SQL for you to adapt. The workflow tells the agent to run EXPLAIN ANALYZE, which executes the query against your database, and to create indexes with CREATE INDEX, which changes the schema. The agent needs a database connection or pasted plans from you to follow those steps.