/microsoft-sql-admin:investigate-sql-memory-issues [TopN] [MemoryThreshold] [ConfirmLookbackMinutes] [HistoryLookbackHours] [MinGrantKB]from Microsoft SQL administration
Investigates SQL Server and Azure SQL memory pressure: out-of-memory errors, RESOURCE_SEMAPHORE waits, memory grant contention, tempdb spills, and low PLE. Runs layered diagnostics on memory clerks, grant pools, and query store patterns.
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.
This is the primary entry point for investigating memory pressure and memory-related issues in SQL Server and Azure SQL. Use when a user reports:
RESOURCE_SEMAPHORE or RESOURCE_SEMAPHORE_QUERY_COMPILE waitsThis skill orchestrates a layered investigation:
resource-usage-sqlserver skill; for a broad instance health audit, use the health-audit-sqlserver skill.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.SELECT @@SERVERNAME, DB_NAME(), SUSER_SNAME(), SERVERPROPERTY('EngineEdition')).Permissions:
VIEW SERVER STATE for server-level DMVs (Steps 1c, 2, 3, 4, 6).VIEW SERVER STATE or VIEW SERVER PERFORMANCE STATE.VIEW DATABASE STATE for database-scoped DMVs (Steps 1b, 5, 7). Steps 2 and 4 use server-scoped DMVs (sys.dm_exec_query_resource_semaphores, sys.dm_os_memory_clerks) that require VIEW SERVER STATE — on Azure SQL DB these may require membership in the ##MS_ServerStateReader## server role.| Parameter | Default | Description |
|---|---|---|
| TopN | 10 | Number of top queries/sessions to return in each step |
| MemoryThreshold | 90 | Memory usage percentage threshold for confirming pressure |
| ConfirmLookbackMinutes | 30 | Window (minutes) for the sys.dm_db_resource_stats memory confirmation check |
| HistoryLookbackHours | 24 | Lookback window (hours) for plan-cache and Query Store queries |
| MinGrantKB | 5120 | Minimum memory grant size (KB) to include in historical analysis (default = 5 MB) |
Step 1 detects the engine edition first, then routes to the correct query:
| EngineEdition | Platform | DMV |
|---|---|---|
| 5 | Azure SQL Database | sys.dm_db_resource_stats |
| 8 | Azure SQL Managed Instance | sys.dm_os_sys_memory + sys.dm_os_process_memory + perf counters (same as on-prem; sys.dm_db_resource_stats not available on MI) |
| 12 | Fabric SQL Database | sys.dm_db_resource_stats |
| 6 | Azure Synapse Analytics (Dedicated SQL pool) | Not supported — memory management differs significantly |
| 11 | Azure Synapse serverless SQL pool / Fabric Warehouse | Not supported — memory management differs significantly |
| other | SQL Server on-prem / IaaS | sys.dm_os_sys_memory + sys.dm_os_process_memory + perf counters |
Read references/queries.md for all SQL queries and execute each step with the SQL query tool. Steps 2, 3, and 4 target live DMV state — run them while memory pressure is active. Steps 6 and 7 cover historical data and can be run at any time.
Load Step 1 from references/queries.md. First run the Step 1a platform-detection query to
get engine_edition. Then run Step 1b (Azure SQL DB / Fabric, editions 5/12) or Step 1c (MI / on-prem, edition 8 or other) —
never both. If no rows returned (Azure) or no pressure signals (on-prem), skip Steps 2–4 and
proceed to Steps 5–7 for historical analysis.
Load and execute the Step 2 query. Key signal: waiter_count > 0 means queries are actively
blocked waiting for memory grants — this is the most acute form of memory pressure.
Load and execute the Step 3 query. Shows sessions holding or waiting for grants. Sessions with
grant_time IS NULL are waiting. Look for over-granted sessions (using < 20% of grant).
Load and execute the Step 4 query. Identifies which internal components consume the most memory. Buffer pool dominance is normal — only concerning when paired with low available memory or IO waits.
Load and execute the Step 5 query. Available only on Azure SQL DB / MI / Fabric (editions 5, 8, 12). On SQL Server on-prem, returns informational message — skip and rely on Steps 2–4.
Load and execute the Step 6 query. Version-gated: full grant columns (max_grant_kb, total_spills,
etc.) on SQL 2017+ / Azure SQL; fallback query on older versions. Identifies queries that
historically request the largest memory grants.
Load and execute the Step 7 queries (two versions: by query hash for pattern analysis, by query ID/plan ID for drill-down). Requires Query Store enabled — skip if not available.
IN (5, 8, 12).sys.dm_os_out_of_memory_events exists only on Azure SQL / MI / Fabric — query has runtime guard.total_spills, max_grant_kb, etc. are SQL 2017+ only — query uses sp_executesql with version gate.MEMORYCLERK_SQLBUFFERPOOL being the largest clerk is normal. Only flag when paired with low available memory, high PAGEIOLATCH_* waits, or low PLE.avg_query_max_used_memory is in 8KB pages — multiply by 8/1024 for MB.Read references/report-template.md to format the final report.
Read references/remediation-guide.md to determine the dominant root cause based on memory clerk patterns, grant status, and OOM events, then prescribe next steps.
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