Skip to content

SQL Optimizer

Caution

Analyzes SQL queries for performance issues, rewrites slow queries, recommends index strategies, and explains execution plans across PostgreSQL, MySQL, and SQLite.

By Data Skills Lab 5,670 stars v2.2.0 Updated 2026-03-10
$ Copy the SKILL.md file to your project's .claude/skills/ directory

About This Skill

SQL Optimizer analyzes your queries and database schema to find performance bottlenecks and suggest improvements. It understands execution plans, index selection, join strategies, and query planner behavior across PostgreSQL, MySQL, and SQLite.

How It Works

  1. Query analysis — Parses SQL to identify anti-patterns like SELECT *, implicit type casts, and missing WHERE clauses
  2. Execution plan review — Reads EXPLAIN/EXPLAIN ANALYZE output to find sequential scans, hash joins, and sort operations
  3. Index recommendation — Suggests indexes based on WHERE, JOIN, ORDER BY, and GROUP BY columns
  4. Query rewrite — Transforms slow patterns: N+1 to JOINs, correlated subqueries to CTEs, DISTINCT to EXISTS
  5. Benchmark comparison — Provides before/after cost estimates from execution plans

Best For

  • Optimizing slow API endpoints caused by inefficient queries
  • Database performance audits before scaling infrastructure
  • Reviewing ORM-generated queries for hidden performance issues
  • Learning SQL optimization patterns through explained rewrites

Database Support

Full support for PostgreSQL (including JSONB, array operations, and partial indexes), MySQL/MariaDB, SQLite, and basic support for SQL Server and Oracle.

Use Cases

  • Analyze EXPLAIN output and identify missing indexes
  • Rewrite N+1 queries into efficient JOINs or subqueries
  • Optimize complex aggregation queries with window functions
  • Convert correlated subqueries to lateral joins or CTEs
  • Recommend composite index strategies for multi-column filters

Pros & Cons

Pros

  • +Explains execution plans in plain language
  • +Handles PostgreSQL-specific features like JSONB and partial indexes
  • +Provides before/after cost comparison for rewrites
  • +Catches ORM-generated query anti-patterns

Cons

  • -Execution plan analysis requires actual EXPLAIN output from the database
  • -Cannot account for data distribution without table statistics

Related Skills

FAQ

What does SQL Optimizer do?
Analyzes SQL queries for performance issues, rewrites slow queries, recommends index strategies, and explains execution plans across PostgreSQL, MySQL, and SQLite.
What platforms support SQL Optimizer?
SQL Optimizer is available on Claude Code, Cursor, OpenAI Codex CLI.
What are the use cases for SQL Optimizer?
Analyze EXPLAIN output and identify missing indexes. Rewrite N+1 queries into efficient JOINs or subqueries. Optimize complex aggregation queries with window functions.

100+ free AI tools

Writing, PDF, image, and developer tools — all in your browser.

Next Step

Use the skill detail page to evaluate fit and install steps. For a direct browser workflow, move into a focused tool route instead of staying in broader support surfaces.