Whenever a SQL query could run but is waiting for another resource, information about the reason for the wait is recorded. You can access it through sys.dm_os_wait_stats.
Here are a couple of ready-made scripts to make sense of it:
- A script from Ian Stirk’s article “Uncover Hidden Data to Optimize Application Performance,” published in MSDN Magazine back in 2008. It lists wait types ordered by time, from the most prominent to the least.
- A script from Paul Randal’s article about analyzing MS SQL Server waits; there’s also a Russian translation on Habr. It filters out waits that always occur and can usually be ignored. It also adds a link to a detailed explanation of each wait, such as this description of CXPACKET.