/microsoft-sql-admin:investigate-sql-log-io-pressure [TopN] [LogIoThreshold] [ConfirmLookbackMinutes] [HistoryLookbackHours] [MinExecutionCount] [MinTotalLogicalWrites]from Microsoft SQL administration
Diagnoses SQL Server log IO pressure causing slow commits and write lag. Checks WRITELOG waits, log throughput, VLF health, and identifies log-generating sessions.
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.
For data IO pressure (PAGEIOLATCH waits, physical reads, buffer pool issues), use the
investigate-sql-data-io-pressureskill instead.
resource-usage-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')).| Parameter | Default | Description |
|---|---|---|
| TopN | 10 | Number of top sessions/queries to return in each step |
| LogIoThreshold | 80 | Log write percentage threshold for confirming pressure (Azure SQL) |
| ConfirmLookbackMinutes | 10 | Window (minutes) for the resource stats confirmation check |
| HistoryLookbackHours | 12 | Lookback window (hours) for the plan-cache history query |
| MinExecutionCount | 10 | Minimum execution count for a plan to appear in Step 5 |
| MinTotalLogicalWrites | 50000 | Minimum cumulative total_logical_writes for Step 5 |
DBCC SHRINKFILE and ALTER DATABASE ... MODIFY FILE)
are recommendations only.Execute all steps in order. Step 2 targets live sessions — run while log IO pressure is active. Steps 3–5 cover cumulative or historical data and can be run at any time.
Execute with the SQL query tool. Detects the SQL Server engine edition at runtime and routes to the appropriate DMV to confirm sustained log IO pressure.
| EngineEdition | Platform | DMV | Notes |
|---|---|---|---|
| 5 | Azure SQL Database | sys.dm_db_resource_stats | avg_log_write_percent — ~15s intervals, ~1h history |
| 8 | Azure SQL Managed Instance | sys.dm_db_resource_stats | Same as Azure SQL DB |
| 12 | Fabric SQL Database | sys.dm_db_resource_stats | Behaves like Azure SQL Database |
| 6 | Azure Synapse Analytics (Dedicated SQL pool) | N/A | Not supported — log IO metrics differ significantly in DW |
| 11 | Azure Synapse serverless SQL pool / Fabric Warehouse | N/A | Not supported — log IO metrics differ significantly in DW/Warehouse environments |
| other | SQL Server on-prem / IaaS | sys.dm_os_wait_stats | Cumulative WRITELOG waits since restart |
Query: See references/queries.md#step-1-detect-platform-and-confirm-log-io-pressure
Interpret: Azure SQL: avg_log_write_percent >= threshold = confirmed (near 100% = hitting log rate limit). On-prem: WRITELOG waits are cumulative since restart. High writelog_wait_count = frequent small commits.
| Assessment | Action |
|---|---|
| Log IO pressure confirmed | Proceed to Step 2 — identify active log generators |
| Intermittent spikes | Steps 2–3 to catch offenders; Step 4 for log space/VLF issues |
| No sustained pressure | Skip Step 2. Steps 3–5 for historical and structural analysis |
is_unsupported_dw = 1 | Stop — this skill does not apply to Azure Synapse (edition 6) or Synapse serverless / Fabric Warehouse (edition 11). Fabric SQL Database (edition 12) is supported. |
Execute with the SQL query tool. Shows active sessions generating transaction log IO. Joins
sys.dm_tran_session_transactionsandsys.dm_tran_database_transactionsto show actual log bytes used per session — a direct measure of log generation, not just write counts.
Query: See references/queries.md#step-2-real-time-log-io-consumers--sessions-with-writelog-waits-and-log-bytes
Interpret: log_bytes_used = actual log generated by session's transaction. log_mb_used > 10 = significant. txn_duration_sec = how long transaction has been open (holds log space). log_bytes_reserved = space reserved for rollback.
| Finding | Recommendation |
|---|---|
WRITELOG wait + high log_bytes_used | Active log generator hitting flush latency — check Step 3 |
log_mb_used > 100 MB | Large transaction — batch into smaller transactions |
Long txn_duration_sec (> 300s) | Long-running transaction preventing log truncation — review design |
Many small log_bytes_used all on WRITELOG | Frequent small commits — batch them |
Execute with the SQL query tool. Measures log file IO latency from
sys.dm_io_virtual_file_stats, filtered to LOG files only. This isolates log write performance from data file performance.
Azure SQL context: In Azure SQL Database, log write metrics reflect the workload behavior within the service tier's log rate governance limits. High write latency typically indicates the database is approaching or hitting its maximum log throughput — not that the underlying storage is slow.
Interpret: avg_log_write_latency_ms > 5 = slow log flushes (healthy OLTP < 2ms). avg_bytes_per_write < 4KB = many tiny commits. Values are cumulative since restart.
| Finding | Recommendation |
|---|---|
avg_log_write_latency_ms > 5 (on-prem) | Dedicate a fast drive (SSD/NVMe) for transaction log |
avg_log_write_latency_ms > 5 (Azure SQL) | Hitting log throughput limit — scale up tier |
Small avg_bytes_per_write (< 4KB) | Too many small commits — batch DML operations |
High log_reads | Frequent rollbacks or replication reads — investigate aborted transactions |
Execute with the SQL query tool. Analyzes transaction log space usage, Virtual Log File (VLF) count, and identifies what is preventing log truncation. Excessive VLFs cause log IO overhead; log reuse blockers cause log growth.
Note:
log_space_in_bytes_since_last_backuprequires SQL Server 2014+ or Azure SQL. On older versions (SQL 2012), this column is omitted.
Note:
sys.dm_db_log_statsrequires SQL Server 2016 SP2+ or Azure SQL. On older versions, this step returns a compatibility message.
Query: See references/queries.md#step-4b-vlf-count-and-log-stats
Query: See references/queries.md#step-4c-active-transactions-holding-log-space
Interpret:
used_log_space_pct > 80% = log mostly full. log_since_last_backup_mb high = infrequent log backups.total_vlf_count > 1000 = excessive VLFs causing IO overhead. log_truncation_holdup_reason: LOG_BACKUP = need log backup; ACTIVE_TRANSACTION = long-running txn; REPLICATION/AVAILABILITY_REPLICA = secondary lagging; NOTHING = healthy.txn_duration_sec + log_mb_used = holding log space, preventing truncation.| Finding | Recommendation |
|---|---|
used_log_space_pct > 80% | On-prem/MI: Log backup or check truncation blockers. Azure SQL DB/Fabric: Check for long-running txns or replication lag |
total_vlf_count > 1000 | Shrink log, regrow with fixed increments (e.g., 1GB FILEGROWTH) |
LOG_BACKUP holdup | On-prem/MI: Schedule more frequent log backups. Azure SQL DB/Fabric: Service-managed — contact support if persistent |
ACTIVE_TRANSACTION holdup | Resolve the long-running transaction from Step 4c |
| Long-running transactions (> 5 min) | Review application code for missing COMMIT/ROLLBACK |
Execute with the SQL query tool. Identifies queries from the plan cache with the highest cumulative
total_logical_writes, which generate the most transaction log. These are the primary candidates for batching or rewriting to reduce log IO pressure.
Query: See references/queries.md#step-5-log-intensive-patterns--historical-write-heavy-queries
Interpret: logical_writes_per_exec > 1000 = write-heavy query. High execution_count + moderate writes = massive aggregate log generation. max_logical_writes >> avg = variable, possibly parameter-sensitive.
| Finding | Recommendation |
|---|---|
logical_writes_per_exec > 10K | Batch into smaller chunks (5K–10K rows per batch with COMMIT between) |
| High execution count + moderate writes | Wrap related operations in explicit transactions to reduce flush frequency |
| INSERT-heavy workloads | Consider minimal logging (BULK INSERT with TABLOCK in SIMPLE/BULK_LOGGED) |
After completing all steps, read references/report-template.md and present the investigation results using that template.
Use references/root-cause-guide.md to determine the root cause and recommended next steps based on findings from all 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