sql-pro

Optimizes SQL queries, designs database schemas, and analyzes execution plans across major database dialects.

1|Updated Jul 2, 2026
One-click install
npx skills add https://github.com/filippolmt/skills --skill sql-pro-filippolmt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-pro
Source: https://github.com/filippolmt/skills/tree/main/skills/sql-pro
Command: npx skills add https://github.com/filippolmt/skills --skill sql-pro-filippolmt

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Slow queries, missing indexes, and poorly designed schemas degrade application performance, and diagnosing them requires deep knowledge of execution plans, indexing strategies, and dialect-specific behavior across PostgreSQL, MySQL, SQL Server, and Oracle. ## Core Features & Use Cases - Query Optimization: Rewrites correlated subqueries into set-based operations, creates covering indexes, and interprets EXPLAIN ANALYZE output to eliminate sequential scans. - Schema Design: Applies normalization (1NF-3NF), constraints, foreign keys, soft deletes, audit trails, and temporal tables for robust database design. - Dialect Migration: Translates queries between PostgreSQL, MySQL, SQL Server, and Oracle, handling differences in pagination, UPSERT, JSON support, and recursive CTEs. - Use Case: A user's dashboard query takes 30 seconds. The skill analyzes the execution plan, identifies a sequential scan, rewrites the correlated subquery as an aggregation join, and adds a covering index to reach sub-100ms performance. ## Quick Start Ask the assistant to analyze why your SQL query is slow and optimize it with proper indexes and an execution plan review.

Frequently Asked Questions about sql-pro

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a slow SQL query?

Start by running EXPLAIN ANALYZE to see actual row counts versus estimates and identify sequential scans on large tables. Then rewrite correlated subqueries as aggregation joins, filter early before joins, and add covering indexes that include all columns the query touches.

How do I read a PostgreSQL EXPLAIN ANALYZE plan?

Run EXPLAIN with ANALYZE and BUFFERS options, then check for Seq Scan on large tables which signals a missing index, large gaps between estimated and actual rows which means stale statistics, and high buffer read counts which indicate cache misses.

What is the difference between PostgreSQL, MySQL, and SQL Server SQL syntax?

The dialects differ in auto-increment columns (SERIAL vs AUTO_INCREMENT vs IDENTITY), pagination (LIMIT/OFFSET vs OFFSET FETCH), UPSERT (ON CONFLICT vs ON DUPLICATE KEY vs MERGE), and recursive CTEs where SQL Server omits the RECURSIVE keyword. The skill's dialect reference covers these mappings.

When should I use a covering index?

Use a covering index for frequent queries when the index includes all columns the query touches, enabling an index-only scan with no table access. In PostgreSQL, add non-key columns with the INCLUDE clause to keep the index lean.

Why is my NOT IN subquery slow or returning wrong results?

NOT IN fails when the subquery returns NULLs and often performs poorly on large sets. Rewrite it as NOT EXISTS with a correlated subquery, which handles NULLs correctly and lets the optimizer use indexes more effectively.