What are you waiting for

Preview:

Citation preview

What Are You Waiting For? Performing Wait Stat Analysis

Introduction

Jason Strate

e: jstrate@pragmaticworks.com

e: jasonstrate@gmail.com

b: www.jasonstrate.com

t: StrateSQL

Resources jasonstrate.com/go/Waits

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

What Are You Waiting For?

You…

• SQL Server

• Developers

• DBAs

Agenda

Defining

Viewing

Collecting

Reviewing

Agenda

Defining

Viewing

Collecting

Reviewing

Wait, wait… I’ll Tell You

Waits: Resource waits occur when a worker requests access to a resource that is not available because the resource is being used by some other worker or is not yet available.

So What?!

Wait Statistics

Identity

Measure Prioritize

Execution Model (Simplified)

Grocery Store

• Cashier – Scheduler

• Customer – Query

• Checkout Line – Queue

• Running

• Runnable

• Suspended

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

Agenda-ing

Defining

Viewing

Collecting

Reviewing

Wait DMVs

• 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

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.

VIEWING WAIT STATS Demo

Agenda

Defining

Viewing

Collecting

Reviewing

DMV Stats

Management Data Warehouse

Do-It-Yourself

Collect Summarize Analyze

DO-IT-YOURSELF Demo

Agenda

Defining

Viewing

Collecting

Reviewing

Wait Types

• Tied to process – Audit – Buffer – I/O – Indexing – Lock – SQLOS

• Categories – Background – External – Queue

Background Waits

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

Not all inclusive

CXPACKET

• 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

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

LATCH_x

• 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

Additional Resources

•http://is.gd/qWGGnd Waits and Queues

•http://is.gd/gvD80N SQLServerPedia

•http://is.gd/r59976 SQL Server Wait Type

Repository

•http://is.gd/khsduZ Wait Stats Introductory

References

•http://is.gd/dQWFwC Joe Sack

•http://is.gd/VlH71l

•http://is.gd/xggZSA Management Data Warehouse

•http://sqldmvstats.codeplex.com DMVstats

Services Speed development through training, and rapid development services from Pragmatic Works.

Products BI products to covert to a Microsoft BI platform and simplify development on the platform.

Foundation Helping those who do not have the means to get into information technology achieve their dreams.

For more information…

Name: Jason Strate Email: jstrate@pragmaticworks.com Blog: www.jasonstrate.com Resource: jasonstrate.com/go/waits

Recommended