Sql-server – Linking Waits to a process/statement

performancesql-server-2016waits

I'm starting to take on more of a DBA role and trying to get tooled up with scripts and knowledge to help with this.

I have been trying the sp_blizt procs in a dev environment. A key area I'm trying to focus on is understanding Waits.

My question is when you see a list of Waits how do you relate them back to a proc/query that is causing them?

For eg. When I see asyn_network_io, how can I show which client app is causing this and what is it running at the time to cause this?

Best Answer

My question is when you see a list of Waits how do you relate them back to a proc/query that is causing them?

You can't, generally speaking. You mention in a comment on another answer that your monitoring tool shows you a jump in wait stats. If your monitoring tool can't correlate resource spikes to what was running at the time, you have a bad monitoring tool.

Tools that make that easy include

If you're already using one of those and having a hard time, you should schedule a call with a vendor representative to walk you through the product.

You also can't use most scripts to figure out what happened later. You have to catch things while they're happening. Some easy ways to do that (for free):

If you're on SQL Server 2017 or higher, and you have Query Store enabled, it will track aggregated waits stats.

It's up to you to keep track of these things, though.

Best of luck!