310 likes | 364 Views
Inside SQL Server Wait Types. SQL 2005 and SQL 2008. Bob Ward Microsoft Corporation. Microsoft CSS at PASS 2009. Welcome to My World. =. All scripts will be available. Not the best of docs. What is a wait type?. 485 in SQL Server 2008. We created this to help us find bottlenecks
E N D
Inside SQL Server Wait Types SQL 2005 and SQL 2008 Bob Ward Microsoft Corporation
Welcome to My World = All scripts will be available
Not the best of docs What is a wait type? 485 in SQL Server 2008 We created this to help us find bottlenecks In a galaxy, far, far, away we had locks, I/O and network But as time has moved on… we went a bit overboard The name of the type is up to the developer
Let’s look at an example We know we need to wait Common for a SELECT Understands SQLOS scheduling Wait() results in SignalObjectAndWait() Ultimately it always comes down to WaitForSingleObject() or SignalObjectAndWait() • SOS_EventAuto is a wrapper for Windows Kernel Event object
Where do wait types show up? Historical stats Live state legacy Tracing in 2008 In the tools Wait Statistics Counter
BUF latch - sync Common Wait Types Hint: System table or allocation Locks - sync Hint: Your app Hint: I/O delay Andrew Kelly’s talk on Capturing and Analyzing File & Wait Stats Resource Make up ~50 of the wait types Hint: Network or your app
Some Waits may not be bottlenecks Should be called “not waiting” BOL calls these Queue Waits Normal for SQL CLR
Busting the Myth of CXPACKET Sync Craig Freedman Talk is a must read Don’t jump to these
The non BUFFER Latch Sync Same modes as BUFs (KP, SH, UP, EX, DT) Latch class
FGCB_ADD_REMOVE latch Sync SQL Server Engine INSERT “I need to grow” LATCH_EX: FGCB_ADD_REMOVE Need space INSERT mydb.mdf Need space FGCB Autogrow Need space INSERT Moral of the story: Use instant file initialization but…it doesn’t work for the tlog Need space INSERT LATCH_SH: FGCB_ADD_REMOVE
SOS_SCHEDULER_YIELD Forced I/O, Lock, Latch ************************ * * BEGIN STACK DUMP: * 10/17/09 15:51:52 spid 0 * * Non-yielding Scheduler * ************************ Could be preemptive thread(s)
Resource THREADPOOL Applies to any task TDS Login Login Timeout Request = task + worker
What about I/O Waits? Sync Log Writer COMMIT TRAN Flush Log Buffer WRITELOG Mylog.ldf Log Cache Log Buffer INSERT LOGBUFFER Request Log Buffer All buffers in use Copy model Resource Mylog.ldf and .mdf SQLTrace File Resource IO_COMPLETION Page I/O Sort I/O DISKIO_SUSPEND File VDI App Create database files Engine Workers ASYNC_IO_COMPLETION BACKUP WITH SNAPSHOT Zero Log Files Backup media Sync Resource
Queries, Memory, and RESOURCE semaphores Resource Hashes and sorts compiles sys.dm_os_memory_brokers DBCC MEMORYSTATUS
Pre-emptive Waits External May wrap more code than just the API ************************ * * BEGIN STACK DUMP: * 10/17/09 15:51:52 spid 0 * * Non-yielding Scheduler * ************************
What are some I might see? ~190 of these
Extended Events and Waits dm_xe_map_values Begin and End Duration, Total, Max
There are other “waits” “Why can’t I truncate the log” PRECONNECT status A poorly written DLL You decide to throttle backoffs in sys.dm_os_spinlock_stats
Where is THE LIST? The Wait Type Repository Blog
What does MDW tell you about I/O Waits sync reads, sorts, SQLTrace I/O, load CLR assembly Buffer Pool I/O for pages Backups, Recovery, DBM WRITELOG wait time = Log Flush Wait (perfmon) LOGBUFFER is just waiting on folks waiting on WRITELOG
The mapping has changed KB 822101 wrong for 2005 and 2008
What’s About These? Forced Resource External Sync Hot stored proc in SQL Server 2005
Complete the Evaluation Form & Win! Sponsored by Dell • You could win a Dell Mini Netbook– every day – just for handing in your completed form! Each session form is another chance to win! Pick up your Evaluation Form: • Within each presentation room • At the PASS Booth near registration area Drop off your completed Form: • Near the exit of each presentation room • At the PASS Booth near registration area
Visit the Microsoft Technical Learning Center Located in the Expo Hall Microsoft Ask the Experts Lounge Microsoft Chalk Talk Theater Presentations Microsoft Partner Village
Thank you for attending this session and the 2009 PASS Summit in Seattle