SO
SQL Optimizer
🔵 Stable🕐 updated 2026-06-28
🔷 SkillSpec L3
pm-dataeng
Diagnose a slow SQL query and produce a concrete optimization plan. Use when asked to optimize SQL, speed up a slow query, reduce a query's cost/scan, fix a timeout, or review a query plan. Produces an analysis — the likely bottleneck, what the plan is doing wrong (full scans, bad joins, spills), the specific rewrite and index/partition changes, and the expected impact, with the optimized query.
What to give it
▸The query — (and the engine — Postgres, BigQuery, Snowflake, MySQL… optimizations differ).
▸The symptom — slow, expensive (bytes scanned), timing out, or just under review.
▸Context if available — `EXPLAIN`/query plan, table sizes/row counts, existing indexes, partitioning/clustering.
✅ The bar it holds itself to
Every skill in this library self-verifies — these are this skill's own quality checks, straight from its definition.
✓Names the single primary bottleneck, not a scattershot list
✓Predicates are checked for sargability (no functions on indexed columns, no leading `%`)
✓Index/partition recommendations are specific (exact columns), not "add an index"
✓For columnar/cloud engines, addresses bytes scanned & pruning, not just row counts
✓Provides the rewritten query and a way to verify the improvement
⚠️ What it refuses to do
Do not say "add indexes" generically — name the columns and explain which predicate/join they serve
Do not ignore the engine — Postgres index tuning and BigQuery partition pruning are different games
Do not optimize a query that should be a model — repeated heavy logic belongs in a materialized/dbt model
Do not wrap indexed columns in functions in the WHERE clause — it kills index usage (non-sargable)
Do not recommend changes without an expected impact or a way to measure it
Install
npx pm-claude-skills add --agent claude # or codex · cursor · gemini · hermes
# or one-line MCP (every skill, any client):
claude mcp add pm-skills -- npx -y pm-claude-skills-mcp
Related skills
🔌 Embed this skill
Drop this on your blog, docs, or site — it renders a "Run this skill" card:
<div data-pm-skill="sql-optimizer"></div>
<script src="https://mohitagw15856.github.io/pm-claude-skills/embed.js" async></script>
💬 Discussion
SQL Optimizer is one of 750 open-source professional AI agent skills — all SkillSpec L3.
Try them all in the browser · ⭐ Star on GitHub · Browse the full catalog