The Importance of Wait Statistics in SQL Server
-
Upload
grant-fritchey -
Category
Data & Analytics
-
view
210 -
download
1
Transcript of The Importance of Wait Statistics in SQL Server
![Page 1: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/1.jpg)
The Importance of Wait Statistics in Monitoring SQL Server
Grant Fritchey
![Page 3: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/3.jpg)
What is a Wait?
• SQL Server does work• All the work doesn’t occur simultaneously• When a unit of work stops• Threads
– RUNNING– SUSPENDED– RUNNABLE
• Time spent between RUNNING and RUNNING
![Page 4: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/4.jpg)
Why Are Waits Important?
• Why is the server slow• Where is the server slow• Which resources are waiting frequently• Which resources are waiting long• Direct pointer to the cause of poor performance
![Page 5: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/5.jpg)
Where Do I Get Waits
• Sys.dm_os_wait_stats• Sys.dm_db_wait_stats• sys.dm_os_latch_stats
![Page 6: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/6.jpg)
Are Some Waits More Important?
• LATCH_*, PAGELATCH_*• PAGEIOLATCH_*, IO_COMPLETION, WRITELOG• CXPACKET• ASYNC_NETWORK_IO• RESOURCE_SEMAPHORE• BACKUPIO• Lots and lots more• signal_wait_time_ms
![Page 7: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/7.jpg)
Are Some Waits Less Important?
• CXPACKET• WAITFOR• CLR_SEMAPHORE• BROKER_RECEIVE_WAITFOR• ONDEMAND_TASK_QUEUE• Lots and lots more
![Page 8: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/8.jpg)
How Do I Use This Information?
• Filter out the unimportant waits• You know where your system bottlenecks are• Is it system related?• Is it query related?• Is it structure related?
![Page 9: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/9.jpg)
How Do I Know Which Queries Are Waiting?• Sys.dm_os_waiting_tasks
![Page 10: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/10.jpg)
How Do I Know Which Waits A Query Has?• Sys.dm_exec_requests• Extended Events: wait_info
![Page 11: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/11.jpg)
What Happens To Waits Over Time?• DBCC SQLPERF(“sys.dm_os_wait_stats”,CLEAR)• DBCC SQLPERF(“sys.dm_os_latch_stats”,CLEAR)• Instance restart
![Page 12: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/12.jpg)
DEMO: Wait Stats in SQL Monitor
![Page 13: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/13.jpg)
SQL Monitor• Clear insights into SQL Server performance
in real time• Embedded expertise• Alerting• Baselines• Wait stats & expensive queries• Custom Metrics• SQL Monitor
![Page 14: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/14.jpg)
SQL Monitor
• Read more experiences of SQL Monitor from real customers at: www.red-gate.com/products/dba/sql-monitor
• We use it to monitor SQLServerCentral, if you want to see how it works: http://monitor.red-gate.com
![Page 15: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/15.jpg)
Its very simple to use and doesn’t drown me in unnecessary information. It came out on top for being reasonably priced and also functionality. We now have a stable SQL Estate due to SQL Monitor.
Nic Hopper, Senior DBA, Atrium Underwriters Ltd
![Page 16: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/16.jpg)
Documents
• SQL Server Performance Tuning Using Wait Statistics• Performance Tuning Using Waits and Queues (old, but still good)• Wait statistics, or please tell me where it hurts – Paul Randal• What Queries Are Causing My Waits – John Sterret
![Page 17: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/17.jpg)
Thank you for your attention
Q & A
![Page 18: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/18.jpg)
![Page 19: The Importance of Wait Statistics in SQL Server](https://reader031.fdocuments.net/reader031/viewer/2022032115/55b5442dbb61eb403a8b47b9/html5/thumbnails/19.jpg)