Presentation on theme: "SQL Server Wait Statistics Capture, Report, Analyse Rob Risetto Principal Consultant with StrataDB"— Presentation transcript:
SQL Server Wait Statistics Capture, Report, Analyse Rob Risetto Principal Consultant with StrataDB (firstname.lastname@example.org)email@example.com
About Rob SQL Server consultant and cofounder of StrataDB StrataDB - Brisbane based SQL Server Consultancy covering SQL Engine and Business Intelligence Worked with SQL Server for 14 years My focus area Performance Tuning High Availability SQL Engine Architecture and Design SQL Automation via Powershell
Agenda Quick theory refresher on Wait Statistics How/Why Common Wait Types Wait Statistic Analysis Guidelines Capture, Report & Analyse Demos using DMVs SQL Server 2012 Performance Dashboard Powershell Charting
Wait Statistics – How/Why Rather than reinventing the wheel… Let’s use Joe Sack (Microsoft Corporation) slides http://www.digitalconcourse.com/dropzone/MSCOMM/PASSMN/PASSEVT2 0090616/Joe%20Sack%20Performance%20Troubleshooting%20with%20Wa it%20Stats.pdf
Wait Types – Common Ones SOS_SCHEDULER_YIELD Represents a SQLOS worker (thread) that has voluntarily yielded the CPU to another worker. May indicate CPU pressure if very high percentage of all waits (> 80%). CXPACKET A query is parallelized and the parallel threads are not given equal amounts of work to do, or one thread blocks. High number for OLTP system is not good. PAGEIOLATCH_XX This is where SQL Server is waiting for a data page to be read from disk into memory. May indicate Disk IO or Memory pressure.
Wait Statistics – Common Ones PAGELATCH_XX Occurs when a task is waiting on a latch for a buffer that is not in an I/O request. PFS, SGAM, and GAM contention that can occur in tempdb Index hot-spot with concurrent inserts into an index with an identity value key WRITELOG This is the log management system waiting for a log flush to disk. May indicate Disk IO LCK_M_XX This is simply the thread waiting for a lock to be granted and indicates blocking problems.
Wait Statistics – Common Ones IO_COMPLETION This is SQL Server waiting for IOs to complete. May indicate Disk IO bottleneck ASYNC_NETWORK_IO SQL Server is waiting for a client to finish consuming data. Bad programming or network issue. RESOURCE_SEMAPHORE Queries waiting for execution memory (the memory used to process the query operators - like a sort) May indicate memory pressure or a very high concurrent workload.
Guidelines for Analysis Look at the Accumulated Waits - Use to focus investigation effort on performance issue - Is a wait type a high percentage of all waits - Is Signal time > 15% - 20% (may indicate CPU pressure) - Is there a high average wait time for a wait type - eg PageIOLatch average > 20 ms
Guidelines for Analysis Correlate Waits with related DMVs and Perfmon - If IO wait compare IO File Stats, Avg Disk Secs/Read, Avg Disk Secs/Write - If CPU waits, check Processor Time %, sys.dm_os_schedulers (runnable_task_count) - If Memory waits, check Page Life Expectancy, Pending Memory Grants (query workspace)
Guidelines for Analysis Look at Delta Waits to determine current wait statistics Capture Waits history for troubleshooting - Review history to identify high wait periods - Combine with other DMV and Perfmon history capture to correlate and diagnose Use sys.dm_os_waiting_tasks to drilldown current waiting tasks - see interesting patterns - see the query associated with the wait