12/10/2009: Significant updates to the blog. Check back in 2010 for more updates to the wait type table
As part of my talk at the 2009 US PASS Summit here in Seattle called Inside SQL Server Wait Types, I’m creating this blog post as a reference point that can be used to find out information about wait types in SQL Server 2005 and 2008. My hope is that if you have a question about a wait type you encounter with SQL Server 2005, 2008, or beyond, you will use this blog post as the starting point. This blog post should also be used as an enhancement to what you can find at the following SQL Server Books Online topic:
sys.dm_os_wait_stats (Transact-SQL)
Why use this blog post over other references? Because information in this blog post will be based on the the actual product source code and empirical testing of scenarios that cause these wait types.
The Wait Type Table
This table is to be used a repository of wait types as found in sys.dm_os_wait_stats in SQL Server 2005 and 2008. The current list is based on waits found in my recent talk at PASS, requests in the comments of the blog, or ones I’ve seen in BOL, newsgroup postings, etc I think you will find interesting. There is not documentation for all wait types. Not sure there ever will be. But if you see one you think I need to document, please comment this blog post.
Attached to this blog is the wait type table in the form of a spreadsheet. This will allow you to search and sort the data as necessary. However, for purposes of ensuring the information is searchable on he web, I’ve also pasted in the contents of the spreadsheet as part of this section. Any updates to the table will be in the form of an updated spreadsheet attachment and a repost of the pasted able. By default I’ll sort the pasted table by Type in ascending order.
You may ask “Where are all of the Wait Types documented?”. Well no where actually. Some are documented in the BOL as I’ve listed above. My table certainly won’t list out all ~485 wait types that are listed in sys.dm_os_wait_stats. But I will document ones i think may help you and include ones you send comments on you would like to know more information by commenting this blog. One thing that will help you is that I will try to document as many wait types that I can that you can typically “ignore” such as Usage=Background and waits that you can actually safely ignore because they simply are never used in the code. Below the wait type table I’ll also show you other waits I’m working on.
The spreadsheet has the following format:
Type – the name of the wait type as found in sys.dm_os_wait_stats
Area – This describes what part of the code the wait is used such as I/O, SQLOS, Network, Memory, Broker, Buffer, Query, …. Think of this as a keyword you can search on to find out wait types associated with a particular topic.
Usage – this is a Description of how the wait type is used within the engine. In other words why does the wait type exist. The possible values are:
Resource: Waiting for a resource to become available or complete such as I/O, Network, Thread, Memory
Sync: Waiting for synchronization to access a resource or code such as locks, latches, or other memory structures
Forced: Waiting is forced by the code such as Yielding or Sleep
External: These are waits that indicate code is running in Preemptive Mode
Background: Waits used mainly by background tasks to indicate they are waiting for work to do
Ignore: Waits that we could probably remove from the DMV as they are not even used in the code
Version – SQL Server 2005, SQL Server 2008
Description – A description of what this wait type means, where it is used in the code, and how you might encounter it
Action – Suggestion on possible actions you should take if you see this wait type show up as a possible “problem”
Work to be done:
Important Notes
In this section, I list out important notes to keep mind about wait types:
1) We have a found a bug in the way PREMPTIVE_XXX wait types work in SQL Server 2008. In some cases, the engine will count a wait for a PREEMPTIVE_XX wait when the code really didn’t switch to preemptive mode. The scope of how often and which PREEMPTIVE_XXX wait types are affected is difficult to predict. This problem was first reported to me after my PASS talk when a customer ran DBCC FREEPROCCACHE. A large number of PREEMPTIVE_OLEDBOPS waits showed up. This is an example of where the engine marked a PREEMPTIVE_OLEDBOPS wait to free up internal information about a plan in cache when it should only apply to plan with linked servers for non SQL Server providers. We know other situations may apply, but I suspect PREEMPTIVE_OLEDBOPS is one of the wait types that is being “over-counted” in SQL Server 2008.
2) One thing I found as part of this research as I was not aware of is that some wait_type names can appear in SQL 2005 in DMVs like sys.dm_exec_requests but not sys.dm_os_wait_stats. An example of this is CHECKPOINT_QUEUE. In SQL Server 2008, some of these wait_type names were changed to be what I’ll call “optional”. By default the “optional” types show up in sys.dm_os_wait_stats. This explains an explosion of rows in this DMV in SQL Server 2008 not just because we added more. As part of this change, we added an undocumented trace flag 8050 which if enabled when querying sys.dm_os_wait_stats will exclude the “optional” wait types. However, When you enable this trace flag in SQL Server 2008 the number of rows is only reduced by about 50 so don’t think that this is an approach to filter out wait types you can “ignore”. But it does explain why some appeared in DMVs in SQL Server 2005 but not in sys.dm_os_wait_stats. So in the wait type table if you see a wait type that says it applies to both SQL Server 2005 and 2008, but you don’t see this wait type in sys.dm_os_wait_stats in SQL Server 2005, you will now know why.
Other Resources
SQLCAT Waits Stats Per Session CodePlex
SQLCAT SQL 2005 Waits and Queues Whitepaper
What’s Next?
I want this blog post and the attached spreadsheet to be a living document and help feed enhancements to the SQL Server Books Online. So if you encounter a question on a wait type that is confusing or not listed in this post, please post a comment to this blog post or email psssql@microsoft.com. This isn’t to obtain “free support” for a problem but to be used to help enhance and create the right content for the community on this topic. I’ll be posting regular updates to this blog throughout 2010 so take a specific feed and look for updates.
Bob Ward Microsoft
Here are a few:
FT_IFTS_SCHEDULER_IDLE_WAIT
FT_IFTSHC_MUTEX
XE_TIMER_EVENT
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=351342
Hi Bob, I was at you session at PASS and it was great! Both the session and this initiative.
Another idea for a future work would be talk about windbg and some usages of it, for some "basic" troubleshooting.
If this begin to get bigger and bigger, you may want to use CodePlex.
Thanks
Luciano Moreira
I am now capturing wait stats after watching Andrew Kelly's session at PASS and see type BROKER_TASK_STOP as a heavy hitter on SQL2005. BOL only gives some BROKER wait types.
Chris
Hey Chris,
I'll email you as well, but the Broker waits are covered in the following blog post:
http://blogs.msdn.com/sql_service_broker/archive/2008/12/01/service-broker-wait-types.aspx
BROKER_TASK_STOP is explained on there.
I guess wait types that aren't used in code don't need to be added to "ignore" since they won't show up...
Bob's Reply:
Actually there are seveal more wait types in the list as found in sys.dm_os_wait_stats that are not used in the code. These are the ones I'm actually going to use for Ignore.
Thanks for the wait table. It's great to see especially with the description column. Can't wait to see more of it. (Okay bad joke!)
Bob's Reply: Actually not bad<g>
Hi Bob,
Two other comments:
A) The table is getting cut off on the right side on my notebook. Might have to tweak the HTML a bit so that it works for smaller monitors.
Bob's Reply: I'm using Windows Live Writer so not sure how to figure out how this fits with all monitors?
B) How about a wiki, so that people can add stuff like related issues, how to get more information on what's causing the wait, etc, etc, etc? This could turn into quite a great resource but I think the blog format is not as conducive to expansion as other mediums.
Bob's Reply: You are correct but the blog is the only medium through Microsoft I have right now to publish this.
Could you add DBMIRROR_DBM_MUTEX to the list?
BOL says "Identified for informational purposes only. Not supported. Future compatibility is not guaranteed."
This is my highest wait type though...
nm, last comment, found it here
msdn.microsoft.com/.../ms179984%28SQL.90%29.aspx
I usually notice 10-12 TASK MANAGER background threads on most SQL 2005 I manage, only one is usually bound to a task and a worker. The worker is waiting on ONDEMAND_TASK_QUEUE, and when attaching in windbg it has sqlservr!systemTaskThread() on top of its stack. I read a few things about this kind of wait in Santeri Voutilainen's chapter on waits (SQL Server 2005 Practical troubleshooting), I know it is not a concern for performance and it can be disregarded, but I still can figure out precisely what this wait event and these task manager processes are for. Thanks,
David B.
Could you give some more commentary on the BACKUPTHREAD and BACKUPIO wait types, please? I'm having trouble finding really helpful explanations about them online (BoL doesn't explain much).
My context: I'm seeing the BACKUPTHREAD wait for a RESTORE DATABASE command from a local disk on a server with nothing else running. Other databases can restore fine, but for this one database on the differential step of the restore it hangs with this waittype for over 10x how long the restore operation should take. The other kpids under that spid in sysprocesses have a wait type of BACKUPIO. Is there a reason for these backup waits to appear when no backups are going on, just a restore?
Hey Ethan,
You may be interested in this fix. Although no wait types are included in the KB, it could be your problem.
support.microsoft.com/.../en-us