sql-pro

Optimize SQL queries and schemas using execution plan analysis and index selection.

1|Updated May 16, 2026
One-click install
npx skills add https://github.com/enigmaicon-eng/AI-Enterprise-OS --skill sql-pro-enigmaicon-eng
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-pro
Source: https://github.com/enigmaicon-eng/AI-Enterprise-OS/tree/main/examples/claude-skills/skills/sql-pro
Command: npx skills add https://github.com/enigmaicon-eng/AI-Enterprise-OS --skill sql-pro-enigmaicon-eng

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you diagnose slow database queries and fix them with better query structure, indexing, and schema design so performance matches your targets.

Core Features & Use Cases

  • Query Optimization Workflow: Analyze your query and execution plan, rewrite using set-based patterns, and validate improvements with EXPLAIN ANALYZE.
  • Schema & Index Design: Design or adjust schemas and create the right (including covering) indexes to reduce scans and improve join/aggregation performance.
  • Performance Debugging & Verification: Interpret plan outputs (e.g., sequential scans, row estimate mismatches, buffer behavior) and iterate until performance goals are met.

Use cases: You have a query that’s slow, you need to design a schema for reliable constraints and keys, or you want to tune complex constructs like joins, CTEs, window functions, recursive queries, and dialect-specific SQL.

Quick Start

Tell the SQL Pro skill to optimize this query by analyzing its execution plan, recommending specific rewrites and indexes, and verifying the improvement with EXPLAIN ANALYZE.

Frequently Asked Questions about sql-pro

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

FAQPage Schema
How do I optimize slow SQL queries using execution plans?

To optimize slow SQL queries, analyze the execution plan using EXPLAIN ANALYZE to identify sequential scans or row estimate mismatches, then apply set-based rewrites and correct indexes to reduce scan overhead and improve join performance.

What is a covering index and when do I need it for query tuning?

A covering index includes all columns needed for a query, allowing the database to satisfy the request directly from the index without accessing the table. You need it during query tuning to eliminate expensive table lookups for SELECT statements.

How do I tune database schema design for complex joins and CTEs?

Tune database schema design for complex joins and CTEs by adjusting constraints and keys to ensure reliable relationships, then selecting appropriate filtered indexes to accelerate aggregation performance and reduce sequential scan bottlenecks.

Does this SQL optimization approach work with PostgreSQL window functions?

Yes, this SQL optimization approach works with PostgreSQL window functions by interpreting execution plans for buffer behavior and applying dialect-specific set-based rewrites to validate performance improvements across common relational databases.

What's the best way to fix sequential scans in EXPLAIN ANALYZE output?

The best way to fix sequential scans in EXPLAIN ANALYZE output is to identify row estimate mismatches, introduce filtered or covering indexes to target the scanned columns, and verify the performance improvements using before and after metrics.

When should I not use a CTE for SQL query optimization?

You should not use a CTE for SQL query optimization when the database optimizer materializes it, preventing predicate pushdown and causing full scans. Rewrite using set-based patterns or derived tables to allow better execution plan selection.