what are you waiting for? (#sqlsat211)

47
Jason Strate Database Architect Pragmatic Works, Inc. WHAT ARE YOU WAITING FOR?

Upload: jason-strate

Post on 22-Jun-2015

409 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: What are you waiting for? (#SQLSat211)

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?

Page 2: What are you waiting for? (#SQLSat211)

You…

SQL Server

Developers

DBAs

WHAT ARE YOU WAITING FOR?

Page 3: What are you waiting for? (#SQLSat211)

AGENDA

Reviewing Collecting Viewing Defining

Page 4: What are you waiting for? (#SQLSat211)

Defining AGENDA

Reviewing Collecting Viewing Defining

Page 5: What are you waiting for? (#SQLSat211)

Waits & Queues Methodology

WAIT, WAIT… I’LL TELL YOU

Page 6: What are you waiting for? (#SQLSat211)

SO WHAT?!

Page 7: What are you waiting for? (#SQLSat211)

Identity

Measure Prioritize

WAIT STATISTICS

Page 8: What are you waiting for? (#SQLSat211)

Grocery Store

Cashier

Scheduler

Customer

Query

Checkout Line

Queue

Running

Runnable

Suspended

EXECUTION MODEL (SIMPLIFIED)

Page 9: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNING

Page 10: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNABLE RUNNING

Page 11: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNABLE RUNNING

SUSPENDED

WAIT

Page 12: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNING RUNNABLE

SUSPENDED

Page 13: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNING RUNNABLE

WAIT TIME

SUSPENDED

Page 14: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNING

SUSPENDED

RUNNABLE

Page 15: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNING

SUSPENDED

RUNNABLE

Page 16: What are you waiting for? (#SQLSat211)

EXECUTION MODEL (SIMPLIFIED)

RUNNING

SUSPENDED

RUNNABLE

SIGNAL WAIT

TIME

Page 17: What are you waiting for? (#SQLSat211)

Viewing AGENDA

Reviewing Collecting Viewing Defining

Page 18: What are you waiting for? (#SQLSat211)

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

Page 19: What are you waiting for? (#SQLSat211)

WAITS STATS

Page 20: What are you waiting for? (#SQLSat211)

WAITS STATS

Name of the wait type.

Page 21: What are you waiting for? (#SQLSat211)

WAITS STATS

Number of waits on this wait type. This counter is

incremented at the start of each wait.

Page 22: What are you waiting for? (#SQLSat211)

WAITS STATS

Total wait time for this wait type in milliseconds. This

time is inclusive of signal_wait_time_ms.

Page 23: What are you waiting for? (#SQLSat211)

WAITS STATS

Maximum wait time on this wait type.

Page 24: What are you waiting for? (#SQLSat211)

WAITS STATS

Difference between the time that the waiting thread

was signaled and when it started running.

Page 25: What are you waiting for? (#SQLSat211)

WAITING TASKS

Page 26: What are you waiting for? (#SQLSat211)

WAITING TASKS

Page 27: What are you waiting for? (#SQLSat211)

WAITING TASKS

ID of the session associated with the task.

Page 28: What are you waiting for? (#SQLSat211)

WAITING TASKS

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

time is inclusive of signal_wait_time.

Page 29: What are you waiting for? (#SQLSat211)

WAITING TASKS

Name of the wait type.

Page 30: What are you waiting for? (#SQLSat211)

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 31: What are you waiting for? (#SQLSat211)

WAITING TASKS

Difference between the time that the waiting thread

was signaled and when it started running.

Page 32: What are you waiting for? (#SQLSat211)

Demo VIEWING WAIT STATS

Page 33: What are you waiting for? (#SQLSat211)

Collecting AGENDA

Reviewing Collecting Viewing Defining

Page 34: What are you waiting for? (#SQLSat211)

DMV STATS

Page 35: What are you waiting for? (#SQLSat211)

MANAGEMENT DATA WAREHOUSE

Page 36: What are you waiting for? (#SQLSat211)

Collect Summarize Analyze

DO-IT-YOURSELF

Page 37: What are you waiting for? (#SQLSat211)

Demo DO-IT-YOURSELF

Page 38: What are you waiting for? (#SQLSat211)

Reviewing AGENDA

Reviewing Collecting Viewing Defining

Page 39: What are you waiting for? (#SQLSat211)

Tied to process

Audit

Buffer

I/O

Indexing

Lock

SQLOS

Categories

Background

External

Queue

WAIT TYPES

Page 40: What are you waiting for? (#SQLSat211)

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

Page 41: What are you waiting for? (#SQLSat211)

•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

Page 42: What are you waiting for? (#SQLSat211)

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 43: What are you waiting for? (#SQLSat211)

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 44: What are you waiting for? (#SQLSat211)

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 45: What are you waiting for? (#SQLSat211)

• 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

Page 46: What are you waiting for? (#SQLSat211)

www.operationsmile.org

www.manning.com/delaney

SQL SERVER MVP DEEP DIVES, VOLUME 2

Page 47: What are you waiting for? (#SQLSat211)

Jason Strate

e: [email protected]

e: [email protected]

b: www.jasonstrate.com

t: StrateSQL

Resources jasonstrate.com/go/Waits2013/

RESOURCES