what are you waiting for

48
What Are You Waiting For? Performing Wait Stat Analysis

Upload: jason-strate

Post on 22-Jun-2015

243 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: What are you waiting for

What Are You Waiting For? Performing Wait Stat Analysis

Page 2: What are you waiting for

Introduction

Jason Strate

e: [email protected]

e: [email protected]

b: www.jasonstrate.com

t: StrateSQL

Resources jasonstrate.com/go/Waits

MAKING BUSINESS INTELLIGENT www.pragmaticworks.com

Page 3: What are you waiting for

What Are You Waiting For?

You…

• SQL Server

• Developers

• DBAs

Page 4: What are you waiting for

Agenda

Defining

Viewing

Collecting

Reviewing

Page 5: What are you waiting for

Agenda

Defining

Viewing

Collecting

Reviewing

Page 6: What are you waiting for

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.

Page 7: What are you waiting for

So What?!

Page 8: What are you waiting for

Wait Statistics

Identity

Measure Prioritize

Page 9: What are you waiting for

Execution Model (Simplified)

Grocery Store

• Cashier – Scheduler

• Customer – Query

• Checkout Line – Queue

• Running

• Runnable

• Suspended

Page 10: What are you waiting for

Execution Model (Simplified)

RUNNING

Page 11: What are you waiting for

Execution Model (Simplified)

RUNNABLE RUNNING

Page 12: What are you waiting for

Execution Model (Simplified)

RUNNABLE RUNNING

SUSPENDED

WAIT

Page 13: What are you waiting for

Execution Model (Simplified)

RUNNING RUNNABLE

SUSPENDED

Page 14: What are you waiting for

Execution Model (Simplified)

RUNNING RUNNABLE

WAIT TIME

SUSPENDED

Page 15: What are you waiting for

Execution Model (Simplified)

RUNNING

SUSPENDED

RUNNABLE

Page 16: What are you waiting for

Execution Model (Simplified)

RUNNING

SUSPENDED

RUNNABLE

Page 17: What are you waiting for

Execution Model (Simplified)

RUNNING

SUSPENDED

RUNNABLE

SIGNAL WAIT TIME

Page 18: What are you waiting for

Agenda-ing

Defining

Viewing

Collecting

Reviewing

Page 19: What are you waiting for

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

Page 20: What are you waiting for

Waits Stats

Page 21: What are you waiting for

Waits Stats

Name of the wait type.

Page 22: What are you waiting for

Waits Stats

Number of waits on this wait type. This counter is

incremented at the start of each wait.

Page 23: What are you waiting for

Waits Stats

Total wait time for this wait type in milliseconds. This

time is inclusive of signal_wait_time_ms.

Page 24: What are you waiting for

Waits Stats

Maximum wait time on this wait type.

Page 25: What are you waiting for

Waits Stats

Difference between the time that the waiting thread

was signaled and when it started running.

Page 26: What are you waiting for

Waiting Tasks

Page 27: What are you waiting for

Waiting Tasks

Page 28: What are you waiting for

Waiting Tasks

ID of the session associated with the task.

Page 29: What are you waiting for

Waiting Tasks

Total wait time for this wait type, in milliseconds. This

time is inclusive of signal_wait_time.

Page 30: What are you waiting for

Waiting Tasks

Name of the wait type.

Page 31: What are you waiting for

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

Page 32: What are you waiting for

Waiting Tasks

Difference between the time that the waiting thread

was signaled and when it started running.

Page 33: What are you waiting for

VIEWING WAIT STATS Demo

Page 34: What are you waiting for

Agenda

Defining

Viewing

Collecting

Reviewing

Page 35: What are you waiting for

DMV Stats

Page 36: What are you waiting for

Management Data Warehouse

Page 37: What are you waiting for

Do-It-Yourself

Collect Summarize Analyze

Page 38: What are you waiting for

DO-IT-YOURSELF Demo

Page 39: What are you waiting for

Agenda

Defining

Viewing

Collecting

Reviewing

Page 40: What are you waiting for

Wait Types

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

• Categories – Background – External – Queue

Page 41: What are you waiting for

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

Page 42: What are you waiting for

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

Page 43: What are you waiting for

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

Page 44: What are you waiting for

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

Page 45: What are you waiting for

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

Page 46: What are you waiting for

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

Page 47: What are you waiting for

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

Page 48: What are you waiting for

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: [email protected] Blog: www.jasonstrate.com Resource: jasonstrate.com/go/waits