Skip to main content

sql-optimizer

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.

소스 정보

저장소
mohitagw15856/pm-claude-skills
최근 소스 활동
2026년 6월 27일 23:15
감지된 SKILL.md 언어
영어
스타
1,320
포크
232

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
sql-optimizer
description
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.
# SQL Optimizer Skill A slow query almost always has a specific, findable cause — a missing index, a non-sargable predicate, a join that explodes rows, a scan that should be a seek. This skill diagnoses it: read what the query (and plan, if given) is actually doing, name the bottleneck, and produce a concrete rewrite plus the index / partition / structural changes — with the expected impact, not vague "add indexes" advice. ## Required Inputs Ask for these only if they aren't already provided: - **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. ## Output Format ### SQL Optimization: [query purpose] **1. What it's doing now** — read the query (and plan): the scans, joins, sorts, and where the time/cost goes. Name the **primary bottleneck** (don't list ten micro-tweaks — find the one that matters). **2. The problems** — ranked, each with *why* it's slow: - Non-sargable predicates (functions on indexed columns, leading wildcards) → can't use an index. - Missing/`wrong index or partition pruning; full scans where a seek is possible. - Join issues — fan-out, wrong join order, missing join keys, `SELECT *` pulling everything. - Sorts/spills, `DISTINCT`/`GROUP BY` on high-cardinality, correlated subqueries that should be joins. - Engine-specific: BigQuery/Snowflake → bytes scanned (partition/cluster pruning), not row counts. **3. The fix** — the **rewritten query**, plus the index / partition / clustering / materialization changes. Be specific (`CREATE INDEX … ON … (cols)`, partition on `event_date`). **4. Expected impact** — roughly what each change buys (seek vs. scan, pruning N% of partitions, removing a sort) and how to verify (re-run `EXPLAIN`, compare bytes/rows). ## Quality Checks - [ ] 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 ## Anti-Patterns - [ ] 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 ## Based On Query-optimization practice — sargability, index/partition pruning, join-order and fan-out, plan reading, columnar bytes-scanned tuning.
GitHub에서 보기