Web Analytics Made Easy - Statcounter

SQL Server Wait Types Cheat Sheet for Performance Tuning

Monitoring wait stats is a key part of SQL Server performance tuning. This cheat sheet summarizes common wait types, their causes, and recommended actions.

1️⃣ CPU and Parallelism Waits

Wait TypeDescriptionCommon CausesTuning Tips
SOS_SCHEDULER_YIELDQuery yielded CPU to allow others to runHigh CPU usage, poor query plansOptimize queries, indexes, and consider scaling CPU
CXPACKETWaiting for parallel threads to finishParallel query imbalanceAdjust MAXDOP, update statistics, tune parallel plans
CXCONSUMERWorker threads consuming parallel streamsNormal after SQL 2017 for CXPACKETInvestigate only if excessive

2️⃣ I/O Waits (Disk Bottlenecks)

Wait TypeDescriptionCommon CausesTuning Tips
PAGEIOLATCH_*Waiting for a page to be read from diskSlow I/O, missing indexesAdd proper indexes, tune queries, move to faster storage (SSD)
WRITELOGWaiting for log to flush to diskLarge transactions, slow log diskUse fast storage for log, commit in smaller batches
ASYNC_IO_COMPLETIONWaiting for async I/O completionBackup/restore, I/O saturationMonitor backup jobs, consider faster disks

3️⃣ Memory and Resource Waits

Wait TypeDescriptionCommon CausesTuning Tips
RESOURCE_SEMAPHOREWaiting for query memory grantMemory pressure, large sorts/joinsAdd RAM, reduce query memory needs, optimize joins
MEMORY_ALLOCATION_EXTWaiting for memory allocationFragmented memory or low memoryMonitor memory usage, optimize workloads
PAGE_LATCH_*Waiting for access to in-memory page latchContention on heavily updated pagesUse partitioning, optimize inserts/updates

4️⃣ Locking and Blocking Waits

Wait TypeDescriptionCommon CausesTuning Tips
LCK_M_S / LCK_M_XWaiting for shared/exclusive lockBlocking transactionsReduce transaction scope, use RCSI (Read Committed Snapshot Isolation)
LATCH_*Waiting for internal memory structure latchContention on tempdb or system pagesUse multiple tempdb files, reduce contention
ASYNC_NETWORK_IOWaiting for client to read resultsNetwork slowness, client-side processingOptimize network, fetch only required columns

5️⃣ Other Common Waits

Wait TypeDescriptionCommon CausesTuning Tips
NETWORK_IOWaiting for network writesSlow network or large result setsReduce dataset size, optimize queries
BACKUPIO / BACKUPBUFFERWaiting during backup operationsBackup throttling or disk I/OUse striped backups, faster disk or backup to Azure
PREEMPTIVE_OS_WAITWaiting for OS-level operationsExternal resources or file I/OCheck antivirus, OS I/O, or external calls

🛠 How to Monitor Wait Stats

Check Cumulative Waits

SELECT TOP 20 wait_type, waiting_tasks_count, wait_time_ms/1000 AS WaitSec
FROM sys.dm_os_wait_stats
WHERE wait_type NOT IN ('SLEEP_TASK','SLEEP_SYSTEMTASK','BROKER_EVENTHANDLER')
ORDER BY wait_time_ms DESC;

Check Active Requests

SELECT session_id, wait_type, blocking_session_id, wait_time, last_wait_type
FROM sys.dm_exec_requests
WHERE status = 'suspended';

Best Practices for Reducing Waits

  1. Tune queries and indexes to reduce I/O and CPU waits
  2. Monitor blocking and deadlocks using sys.dm_exec_requests and Extended Events
  3. Check tempdb usage and configure multiple data files for concurrency
  4. Use Query Store to analyze regressions and high-wait queries
  5. Baseline wait stats to identify abnormal spikes

This cheat sheet is ideal for DBAs and developers to quickly diagnose SQL Server performance issues.


Discover more from Technology with Vivek Johari

Subscribe to get the latest posts sent to your email.

Leave a Reply

Discover more from Technology with Vivek Johari

Subscribe now to keep reading and get access to the full archive.

Continue reading