A plugin for ChatGPT, Codex and Claude that reviews SQL Server execution plans (.sqlplan / showplan XML) and Query Store exports. It finds where the work really goes, traces misestimates to their origin, and reports findings with evidence and fixes.
Hugo Kornelis devoted years, and the last of his strength, to explaining SQL Server execution plans with rare depth and precision. In 2018 he started the free SQL Server Execution Plan Reference. He kept working on it through his battle with leukemia, and by October 2026 every operator he knew of was documented. He passed away on November 3, 2026. His knowledge was matched only by his generosity and kindness. This project builds on his work and is published in his name.
Created by Barak Gal.
- Reads the plan correctly: tells actual plans from estimated ones, and compares rows per execution × executions with actual rows.
- Finds misestimate origins: the operators where estimates first go wrong, so diagnosis starts in the right place.
- Ranks real cost: by self time and logical reads, never by estimated cost %.
- Detects problem patterns: spills, memory-grant issues, lookup storms, residual predicates, implicit conversions, eager index spools, OR in join conditions, parallel skew, scalar UDFs, fixed-guess functions, stale statistics, ad hoc plan churn.
- Avoids traps: values the plan reports misleadingly, and warnings that can be false positives.
- Works with Query Store: reads exports from the included PowerShell collector or SQL scripts.
plugin.json ChatGPT / Codex manifest (OpenAI settings under extensions.com.openai)
.claude-plugin/plugin.json Claude manifest
skills/sqlserver-plan-review/ the skill (shared by both)
├── SKILL.md workflow, ground rules, thresholds, report template
├── references/
│ ├── reading.md how to read; metric meanings; misleading values; false-positive warnings
│ ├── symptoms.md symptom → evidence → cause → fix
│ ├── patterns.md recognisable plan shapes
│ ├── operators.md operator behaviour and traits
│ ├── xml-map.md SSMS property ↔ showplan XML
│ ├── query-store-export.md reading Query Store exports, flag glossary, ad hoc work
│ └── plan-capture-and-query-store.md collecting plans, Query Store, plan control
└── scripts/
├── plan_digest.py plan parser / problem detector (Python 3, standard library only)
├── query_store_top_plans.sql top Query Store plans per database (read-only)
├── adhoc_plan_cache.sql plan cache ad hoc footprint per server (read-only)
└── Export-QueryStorePlans.ps1 collector you run on Windows against your server
assets/ icon and logo
PRIVACY.md · LICENSE · README.md
| Where | How |
|---|---|
| ChatGPT / Codex | From the plugin directory, once published |
| Claude (claude.ai, Cowork, Claude Code) | From Anthropic's plugin directory, once published |
| Claude Code, manual | claude --plugin-dir ./sqlserver-plan-review for one session, or add this repository as a marketplace |
| ChatGPT desktop, local testing | Add the folder to a local marketplace (see OpenAI's plugin packaging guide) |
.\Export-QueryStorePlans.ps1 # local server, Windows auth, all Query Store databases
.\Export-QueryStorePlans.ps1 -Server PRODSQL01 -User sa -Database 'Sales%' -Days 30 -Top 20 -IncludeFlaggedThe script needs VIEW DATABASE STATE for Query Store and VIEW SERVER STATE for the plan cache summary. Availability-group secondaries that aren't readable are skipped. Without PowerShell, run scripts/query_store_top_plans.sql per database and scripts/adhoc_plan_cache.sql per server.
The digest script works without any AI assistant:
python3 skills/sqlserver-plan-review/scripts/plan_digest.py client_plan.sqlplan- Primary source: Hugo Kornelis' SQL Server Execution Plan Reference, tagged
[EPR:page]→https://sqlserverfast.com/epr/<page>/. [P]marks established plan-review practice;[H]a heuristic or general product knowledge (verify per version);[Schema]the showplan XML schema.- All content is condensed and paraphrased in this project's own words. For full explanations, read the EPR.
- Testing: the scripts were validated on synthetic plans and on live servers through several rounds of fixes. Thresholds are heuristics.
- No server connection: the plugin reads the plans and exports you provide.
- Plan-only sources: Query Store and plan cache plans contain no run-time counters, so some conclusions need an actual plan.
The plugin collects no data; see PRIVACY.md. Plans contain query text and parameter values, so get your client's consent before sharing them with any AI tool.
MIT: free to use, modify and share. The analysis builds on Hugo Kornelis' freely available SQL Server Execution Plan Reference; that work remains his, and this project only paraphrases and links to it.
Open an issue at https://github.com/barak810/sqlserver-plan-review/issues. Pull requests are welcome, especially anonymised plans the digest misreads, and corrections backed by an EPR page.