/microsoft-sql-admin:query-store-volatile-historical-slow-queries-comparison [QueryId] [LookbackMinutes] [TopN]from Microsoft SQL administration
Investigates volatile or intermittent slow queries in SQL Server using Query Store. Analyzes duration variability, wait categories, forced plan failures, parameter sniffing, and memory grants for a specific query_id.
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.
Use this skill to investigate intermittent or persistent slow queries with Query Store:
QueryId across time intervals to see when regressions occurred.RESOURCE_SEMAPHORE risk.SELECT @@SERVERNAME, DB_NAME(), SUSER_SNAME(), SERVERPROPERTY('EngineEdition')).QueryId from Step 1 or the user.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. 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.VIEW SERVER PERFORMANCE STATE (VIEW SERVER STATE before SQL Server 2022) or, on Azure
SQL Database, VIEW DATABASE PERFORMANCE STATE or ##MS_ServerStateReader##, plus any other read
permission these queries need. A tool is only as read-only as the login it connects with.| Parameter | Default | Description |
|---|---|---|
| QueryId | (optional) | Query Store query_id to drill into. If omitted, Step 1 runs first to surface candidates. |
| LookbackMinutes | 120 | How far back to look in Query Store data (in minutes). Used for both steps. |
| TopN | 20 | Number of top volatile queries to return in Step 1. |
LookbackMinutes guidance:
Run the Platform Detection query from references/queries.md before Step 0.
Stop on engine editions 6 or 11; treat edition 12 as Fabric SQL Database and proceed normally.
ALTER DATABASE ... SET QUERY_STORE, including
QUERY_STORE CLEAR, plus sp_query_store_force_plan and sp_query_store_unforce_plan) are
recommendations only.QUERY_STORE CLEAR permanently deletes the
Query Store history, and a forced plan is reverted with sp_query_store_unforce_plan.Load and execute the Step 0 query from references/queries.md.
Key signals: QDS State should be READ_WRITE; if OFF or READ_ONLY, proceed cautiously and note capture limitations in the report.
If no QueryId is provided, run Step 1 from references/queries.md to find candidates.
Key signals: high Coefficient of Variation % marks instability, and Plan Count > 1 points to plan regression or parameter sensitivity.
Run the Step 2 query from references/queries.md for the selected QueryId.
Key signals: high duration with low CPU suggests blocking, high duration with high CPU suggests plan regression, and stable plan with rising reads suggests data growth.
Run the Step 3 query from references/queries.md when wait stats are available.
Key signals: dominant Lock, IO, Memory, CPU, or Parallelism waits explain why the query is slow; skip on SQL Server 2016 or when wait stats capture is off.
Step 3 vs. the standalone
wait-category-analysisskill: Use Step 3 for a lightweight, inline wait-category breakdown of the specificQueryIdalready in scope here — it keeps the investigation in one flow and is enough to point at the dominant wait type. Hand off to the dedicatedwait-category-analysisskill when you need the deeper treatment it owns: the prescriptive root-cause decision tree, recommended next-step skills per wait category, and the standalone report. Do not duplicate or expand the wait analysis here; thewait-category-analysisskill remains the source of truth for that logic.
Run the Step 4 query from references/queries.md to catch failures Step 1 can miss.
Key signals: Aborted points to timeouts or cancellations, Exception points to runtime failures, and high failure count with high duration suggests blocking or starvation.
Run the Step 5 query from references/queries.md if forced plans may be involved.
Key signals: Force Failure Count > 0 means the forced plan is not sticking; use Last Failure Reason to decide whether schema change, compilation, or general failure is responsible.
Run the Step 6 query from references/queries.md to rank high-memory queries.
Key signals: large average memory grants, volatile max-vs-avg memory, and overlap with Step 3 Memory waits indicate RESOURCE_SEMAPHORE pressure.
Run the Step 7 query from references/queries.md for multi-plan analysis.
Key signals: the same Query ID with multiple Plan ID values and large duration gaps is strong evidence of parameter sniffing; compare forced and non-forced plans.
OFF or READ_ONLY does not automatically mean no historical data; later steps may still return useful evidence.LookbackMinutes before concluding there is no volatility.QueryId and check whether the query executed inside the lookback window.references/queries.md.Memory waits are high-priority tuning targets.Use the per-step report templates and interpretation guidance in references/queries.md.
See references/report-template.md for a minimal wrapper when you need a single combined report.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
47 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`.npx claudepluginhub microsoft/microsoft-sql --plugin microsoft-sql-adminOther plugins' skills for the same job