what are you waiting for? (#sqlsat211)
TRANSCRIPT
J a s o n S t r a t e
D a t a b a s e A r c h i t e c t
P r a g m a t i c W o r k s , I n c .
WHAT ARE YOU
WAITING FOR?
You…
SQL Server
Developers
DBAs
WHAT ARE YOU WAITING FOR?
AGENDA
Reviewing Collecting Viewing Defining
Defining AGENDA
Reviewing Collecting Viewing Defining
Waits & Queues Methodology
WAIT, WAIT… I’LL TELL YOU
SO WHAT?!
Identity
Measure Prioritize
WAIT STATISTICS
Grocery Store
Cashier
Scheduler
Customer
Query
Checkout Line
Queue
Running
Runnable
Suspended
EXECUTION MODEL (SIMPLIFIED)
EXECUTION MODEL (SIMPLIFIED)
RUNNING
EXECUTION MODEL (SIMPLIFIED)
RUNNABLE RUNNING
EXECUTION MODEL (SIMPLIFIED)
RUNNABLE RUNNING
SUSPENDED
WAIT
EXECUTION MODEL (SIMPLIFIED)
RUNNING RUNNABLE
SUSPENDED
EXECUTION MODEL (SIMPLIFIED)
RUNNING RUNNABLE
WAIT TIME
SUSPENDED
EXECUTION MODEL (SIMPLIFIED)
RUNNING
SUSPENDED
RUNNABLE
EXECUTION MODEL (SIMPLIFIED)
RUNNING
SUSPENDED
RUNNABLE
EXECUTION MODEL (SIMPLIFIED)
RUNNING
SUSPENDED
RUNNABLE
SIGNAL WAIT
TIME
Viewing AGENDA
Reviewing Collecting Viewing Defining
sys.dm_os_wait_stats
Accumulated statistics on tasks that have waited for resources
sys.dm_os_waiting_tasks
Information on queued tasks waiting for resources
WAIT DMVS
WAITS STATS
WAITS STATS
Name of the wait type.
WAITS STATS
Number of waits on this wait type. This counter is
incremented at the start of each wait.
WAITS STATS
Total wait time for this wait type in milliseconds. This
time is inclusive of signal_wait_time_ms.
WAITS STATS
Maximum wait time on this wait type.
WAITS STATS
Difference between the time that the waiting thread
was signaled and when it started running.
WAITING TASKS
WAITING TASKS
WAITING TASKS
ID of the session associated with the task.
WAITING TASKS
Total wait time for this wait type, in milliseconds. This
time is inclusive of signal_wait_time.
WAITING TASKS
Name of the wait type.
WAITING TASKS
ID of the session that is blocking the request. If this
column is NULL, the request is not blocked, or the
session information of the blocking session is not
available
WAITING TASKS
Difference between the time that the waiting thread
was signaled and when it started running.
Demo VIEWING WAIT STATS
Collecting AGENDA
Reviewing Collecting Viewing Defining
DMV STATS
MANAGEMENT DATA WAREHOUSE
Collect Summarize Analyze
DO-IT-YOURSELF
Demo DO-IT-YOURSELF
Reviewing AGENDA
Reviewing Collecting Viewing Defining
Tied to process
Audit
Buffer
I/O
Indexing
Lock
SQLOS
Categories
Background
External
Queue
WAIT TYPES
CLR_SEMAPHORE
LAZYWRITER_SLEEP
RESOURCE_QUEUE
SLEEP_TASK
SLEEP_SYSTEMTASK
WAITFOR
LOGMGR_QUEUE
CHECKPOINT_QUEUE
XE_TIMER_EVENT
BROKER_TO_FLUSH
BROKER_TASK_STOP
CLR_MANUAL_EVENT
CLR_AUTO_EVENT
XE_DISPATCHER_WAIT
BACKGROUND WAITS
Not all inclusive
•Contention with queries the at are executing in parallel; across multiple CPUs. Generally due to unbalanced execution across CPUs or tasks ahead of query executing longer than expected.
Translation
•>5% for OLTP
•>10% for data warehouses
Guideline
•Review indexing
•Tune queries
•Adjust Max Degree of parallelism
•Research cost threshold for parallelism
Resolution
CXPACKET
OLEDB
• Occurs when SQL Server calls the Microsoft SQL Native Client OLE DB Provider. It indicates the duration of calls to the OLE DB provider.
Translation
• Examine when it is a top wait and exceeds background waits. (TOP 5)
Guideline
• Identify queries with OLE DB waits with extended events or sys.dm_os_waiting_tasks
• Check application placement and Disk secs/Read and Disk secs/Write
• Tune transactions using RPC, Distributed (Linked Server), and Full Text Search
Resolution
PAGEIOLATCH_X
• Contention caused by disk to memory transfer. Typically suggests disk IO subsystem issues.
Translation
• Examine when it is a top wait and exceeds background waits. (TOP 5)
Guideline
• Review Physical disk: disk seconds/read and Physical disk: disk seconds/write and SQL Server Buffer Manager: Page Life Expectancy
• Review information for virtual file stats
• Reconfigure disk to improve IO throughput
• Analyze indexes to reduce need to move data to memory
• Increase memory to increase data available to SQL Server
Resolution
PAGELATCH_X
• Contention between short term light weight synchronization objects. Latches are not held for the duration of a transaction. Occur in the buffer pool but unrelated to IO requests.
Translation
• Examine when it is a top wait and exceeds background waits. (TOP 5)
Guideline
• Check tempdb configuration
• Additional data files
• Trace Flag 1118
• Troubleshoot memory pressure
Resolution
• Contention between short term light weight synchronization objects. Latches are not held for the duration of a transaction. Non buffer pool related.
Translation
• Examine when it is a top wait and exceeds background waits. (TOP 5)
Guideline
• Review T-SQL generating LATCH waits using extended events.
• Examine memory items in sys.dm_os_latch_stats
• Partition table across multiple files
Resolution
LATCH_X
www.operationsmile.org
www.manning.com/delaney
SQL SERVER MVP DEEP DIVES, VOLUME 2
Jason Strate
b: www.jasonstrate.com
t: StrateSQL
Resources jasonstrate.com/go/Waits2013/
RESOURCES