/microsoft-sql-admin:wait-category-analysis [LookbackMinutes] [TopN] [SnapshotDurationSeconds]from Microsoft SQL administration
Diagnoses why SQL queries are slow by categorizing waits into Lock, CPU, IO, Memory, or Network. Requires Query Store with wait stats capture.
Ships in Microsoft SQL administration. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Determines why queries are slow by categorizing waits into Lock, CPU, IO, Memory, or Network. Use after running
query-store-volatile-historical-slow-queries-comparison(Step 1) to diagnose root cause.
microsoft-sql-admin plugin (mssql_list_database_connections,
mssql_connect_database, then mssql_execute_query); any other SQL tool the agent host provides
for running T-SQL and reading result sets;
sqlcmd from a terminal. The
queries only read diagnostics (the snapshot steps use session temp tables and WAITFOR DELAY, so
the tool must allow a multi-statement batch that runs for {{SnapshotDurationSeconds}} seconds).
If the SQL Tools MCP server is not connected or lists no connections, follow the
sql-tools-mcp-setup skill, which asks before installing or configuring anything. If no SQL tool
can be made available, give the user the T-SQL to run and ask for the results.| Parameter | Default | Description |
|---|---|---|
| LookbackMinutes | 60 | How far back to look in Query Store wait stats (minutes) |
| TopN | 20 | Number of top queries to return, ranked by total wait time |
| SnapshotDurationSeconds | 30 | Duration in seconds for the wait stats snapshot window (10–300). The SQL uses a T-SQL CONVERT expression to format as HH:MM:SS — substitute the integer directly. |
ALTER DATABASE ... SET QUERY_STORE,
sp_query_store_force_plan, and UPDATE STATISTICS) are recommendations only.sp_query_store_unforce_plan, and Query Store option changes with the opposite setting.Execute all steps in order. Load and execute queries from references/queries.md — run the SQL exactly as written.
Load references/queries.md. Detects engine edition and validates Query Store is enabled with wait stats capture.
| Assessment | Action |
|---|---|
is_unsupported_dw = 1 | Stop — skill does not apply to SQL DW, Synapse serverless, or Fabric Warehouse/Lakehouse endpoints |
has_instance_wait_stats = 0 (Azure SQL DB / Fabric SQL DB) | Skip Step 2 — use Step 3 instead |
Query Store not READ_WRITE | Enable: ALTER DATABASE CURRENT SET QUERY_STORE = ON |
wait_stats_capture_mode = OFF | Enable: ALTER DATABASE CURRENT SET QUERY_STORE (WAIT_STATS_CAPTURE_MODE = ON) |
Save engine_edition and has_instance_wait_stats for routing.
SQL Server / MI only. Skip for Azure SQL DB and Fabric — use Step 3. This query takes
{{SnapshotDurationSeconds}}seconds — inform the user before executing.
Load and execute from references/queries.md.
Takes two snapshots of sys.dm_os_wait_stats separated by {{SnapshotDurationSeconds}} seconds and diffs them for accurate current-window waits.
Azure SQL DB and Fabric only. Skip for SQL Server / MI — use Step 2. This query takes
{{SnapshotDurationSeconds}}seconds — inform the user before executing.
Load and execute from references/queries.md.
Same snapshot approach as Step 2 but uses sys.dm_db_wait_stats (database-scoped).
All platforms with Query Store. Two query versions available — by Query Hash (default) or by Query ID/Plan ID.
Load and execute from references/queries.md.
| Finding | Recommendation |
|---|---|
| High wait with Lock category | Run check-live-blocking to find head blocker |
| High wait with CPU category | Check plan for missing indexes, outdated stats, or plan regression |
Plan Count > 1 | Possible plan regression or parameter sniffing — run query-store-volatile-historical-slow-queries-comparison (Step 1) |
| High wait with IO category | Check for table scans or missing covering indexes |
SQL Server / MI only. Run only when PAGELATCH_XX waits detected in Steps 2–4.
Load and execute from references/queries.md. Identifies whether contention is on tempdb PFS/GAM/SGAM pages.
Read references/report-template.md before presenting results.
Read references/root-cause-guide.md to determine the primary root cause based on the dominant wait category and identify recommended next steps.
The Wait Stats Auxiliary Mapping Table maps individual wait types to categories with explanations — use it when interpreting results in the report.
sys.dm_os_wait_stats is not available on Azure SQL DB (edition 5) or Fabric (edition 12). Use sys.dm_db_wait_stats instead.sys.dm_db_wait_stats is only available on Azure SQL DB and Fabric — not on SQL Server or MI.WAIT_STATS_CAPTURE_MODE = ON — disabled by default on older versions.WAITFOR DELAY and will take {{SnapshotDurationSeconds}} seconds. Always warn the user.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub microsoft/microsoft-sql --plugin microsoft-sql-admin47 skills in this plugin
/active-connectionsUse when the user asks who is connected, which sessions are idle or hold the oldest open transaction, or how connections split by login or app. If a client can't connect, use `connectivity-troubleshoot`./always-encrypted-columnsUse when the user asks which plaintext columns can or should use Always Encrypted, or why a column is disqualified. Eligibility only: not for listing already-encrypted columns or their keys./authentication-diagnosticsUse when a login fails (18456, 'Login failed for user'), a user can't open a database, a permission is denied, or an Entra or managed identity login fails. For network errors, use `connectivity-troubleshoot`.Other plugins' skills for the same job