Presentation is loading. Please wait.

Presentation is loading. Please wait.

Diagnosing Performance with Wait Statistics Robert L Davis Principal Database

Similar presentations


Presentation on theme: "Diagnosing Performance with Wait Statistics Robert L Davis Principal Database"— Presentation transcript:

1 Diagnosing Performance with Wait Statistics Robert L Davis Principal Database Architect robertd@dbbest.com @SQLSoldier www.sqlsoldier.com

2 Robert L Davis Principal Database Architect at DB Best Technologies Greater Seattle Area | Information Technology and Services Past: Blog: Twitter: LinkedIN: Principal DBA at Outerwall, Inc. P.M. SQL Server Master Certification Program at Microsoft Sr. Database Administrator at Microsoft www.SQLSoldier.com @SQLSoldier www.linkedin.com/in/robertldavis

3 Diagnosing Performance with Wait Statistics “Find the problem, FIX IT. Identify another problem, FIX IT. Repeat as necessary.” ~ Keenan Thompson (Saturday Night Live)

4 Diagnosing Performance with Wait Statistics  Medical approach to troubleshooting

5 Diagnosing Performance with Wait Statistics  Medical approach to troubleshooting  Baseline vital statistics  Performance counters  DMV stats

6 Diagnosing Performance with Wait Statistics  Medical approach to troubleshooting  Baseline vital statistics  Performance counters  DMV stats  Recheck vital statistics and compare

7 Diagnosing Performance with Wait Statistics  Medical approach to troubleshooting  Baseline vital statistics  Performance counters  DMV stats  Recheck vital statistics and compare  Find deviations from the norm

8 Diagnosing Performance with Wait Statistics  Medical approach to troubleshooting  Baseline vital statistics  Performance counters  DMV stats  Recheck vital statistics and compare  Find deviations from the norm  Read more: http://bit.ly/LsoN5xhttp://bit.ly/LsoN5x

9 Diagnosing Performance with Wait Statistics  Baseline for Performance

10 Diagnosing Performance with Wait Statistics  Baseline for Performance  Processor(*)\% Processor Time  PhysicalDisk\Avg. Disk sec/Read  PhysicalDisk\Avg. Disk sec/Write  Memory\Pages/sec  Memory\Available Bytes  SQLServer:Buffer Manager\Page life expectancy  SQLServer:GeneralStatistics\Processes Blocked  SQLServer:Access Methods\Full Scans/sec  SQLServer:SQL Statistics\Batch requests/sec  SQLServer:Buffer Manager\Lazy writes/sec  SQLServer:Buffer Manager\Buffer Cache Hit Ratio  SQLServer:Databases (*)\Transactions/sec

11 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries

12 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  Wait statistics

13 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  Wait statistics  sys.dm_os_wait_stats  sys.dm_os_waiting_tasks  sys.dm_exec_requests  sys.dm_exec_sessions  sys.dm_exec_query_plan()  sys.dm_exec_sql_text()

14 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_wait_stats

15 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_wait_stats  Cumulative since last restart or reset

16 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_wait_stats  Cumulative since last restart or reset  DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);

17 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_wait_stats  Cumulative since last restart or reset  DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);  Total waits on server

18 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_wait_stats  Cumulative since last restart or reset  DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);  Total waits on server  Take a delta to see how they are changing

19 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_wait_stats  Cumulative since last restart or reset  DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);  Total waits on server  Take a delta to see how they are changing  signal_wait_time_ms  Time from when the waiting task has its resource until it starts running  Waiting on CPU thread

20 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_waiting_tasks

21 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_waiting_tasks  Tasks currently waiting on a resource

22 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_waiting_tasks  Tasks currently waiting on a resource  wait_duration_ms

23 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_waiting_tasks  Tasks currently waiting on a resource  wait_duration_ms  wait_type

24 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_waiting_tasks  Tasks currently waiting on a resource  wait_duration_ms  wait_type  blocking_session_id

25 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_os_waiting_tasks  Tasks currently waiting on a resource  wait_duration_ms  wait_type  blocking_session_id  resource_description

26 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_exec_requests

27 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_exec_requests  Currently active requests  Shows wait stats too!  session_id  request_id – for parallel tasks  start_time  status – suspended = waiting  command  database_id  blocking_session_id  wait_type  wait_time  last_wait_type – if not currently waiting  wait_resource

28 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_exec_sessions

29 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_exec_sessions  Currently active sessions  Shows client connection info  Not all sessions have a request  Has some performance stats cumulative over all requests for the entire session  program_name  is_user_process

30 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_exec_query_plan()  Query plan from cache  Requires plan_handle

31 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries  sys.dm_exec_query_plan()  Query plan from cache  Requires plan_handle  sys.dm_exec_sql_text()  SQL text from cache  Requires sql_handle or plan_handle  Provides offset values to identify the currently executing statement in a batch

32 Diagnosing Performance with Wait Statistics  SOS_SCHEDULER_YIELD

33 Diagnosing Performance with Wait Statistics  SOS_SCHEDULER_YIELD  SOS: SQLOS

34 Diagnosing Performance with Wait Statistics  SOS_SCHEDULER_YIELD  SOS: SQLOS  SCHEDULER: manages worker threads onto CPU threads

35 Diagnosing Performance with Wait Statistics  SOS_SCHEDULER_YIELD  SOS: SQLOS  SCHEDULER: manages worker threads onto CPU threads  YIELD: Giving way to another

36 Diagnosing Performance with Wait Statistics  SOS_SCHEDULER_YIELD  SOS: SQLOS  SCHEDULER: manages worker threads onto CPU threads  YIELD: Giving way to another  Waiting for another worker thread to yield the CPU thread

37 Diagnosing Performance with Wait Statistics  PAGE_LATCH / PAGE_IO_LATCH

38 Diagnosing Performance with Wait Statistics  PAGE_LATCH / PAGE_IO_LATCH  PAGE: unit of data storage in SQL Server

39 Diagnosing Performance with Wait Statistics  PAGE_LATCH / PAGE_IO_LATCH  PAGE: unit of data storage in SQL Server  IO: reading (I) and writing (O), in this case disk IO

40 Diagnosing Performance with Wait Statistics  PAGE_LATCH / PAGE_IO_LATCH  PAGE: unit of data storage in SQL Server  IO: reading (I) and writing (O), in this case disk IO  LATCH: Lightweight locking mechanism

41 Diagnosing Performance with Wait Statistics  PAGE_LATCH / PAGE_IO_LATCH  PAGE: unit of data storage in SQL Server  IO: reading (I) and writing (O), in this case disk IO  LATCH: Lightweight locking mechanism  Waiting for a latch on a page in memory or a page on disk

42 Diagnosing Performance with Wait Statistics  CXPACKET

43 Diagnosing Performance with Wait Statistics  CXPACKET  CX: Communication eXchange

44 Diagnosing Performance with Wait Statistics  CXPACKET  CX: Communication eXchange  PACKET: unit of communication

45 Diagnosing Performance with Wait Statistics  CXPACKET  CX: Communication eXchange  PACKET: unit of communication  Parallelism is occurring

46 Diagnosing Performance with Wait Statistics  NETWORK_IO

47 Diagnosing Performance with Wait Statistics  NETWORK_IO  NETWORK: External communication

48 Diagnosing Performance with Wait Statistics  NETWORK_IO  NETWORK: External communication  IO: Reading (I) and writing (O)

49 Diagnosing Performance with Wait Statistics  NETWORK_IO  NETWORK: External communication  IO: Reading (I) and writing (O)  SQL is writing faster than the client is reading

50 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_xxxxx

51 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_xxxxx  PREEMPTIVE: Non-yielding

52 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_xxxxx  PREEMPTIVE: Non-yielding  OS: Operating System

53 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_xxxxx  PREEMPTIVE: Non-yielding  OS: Operating System  xxxxx: The OS operation or API being called  Non-yielding shell out to the Operating System

54 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_AUTHENTICATIONOPS

55 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_AUTHENTICATIONOPS  PREEMPTIVE: Non-yielding  OS: Operating System

56 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_AUTHENTICATIONOPS  PREEMPTIVE: Non-yielding  OS: Operating System  AUTHENTICATIONOPS: The OS operation or API being called

57 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_AUTHENTICATIONOPS  PREEMPTIVE: Non-yielding  OS: Operating System  AUTHENTICATIONOPS: The OS operation or API being called, a group of API calls related to authentication

58 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_AUTHENTICATIONOPS  PREEMPTIVE: Non-yielding  OS: Operating System  AUTHENTICATIONOPS: The OS operation or API being called, a group of API calls related to authentication  Non-yielding shell out to the OS to perform authentication operations

59 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_VERIFYSIGNATURE

60 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_VERIFYSIGNATURE  PREEMPTIVE: Non-yielding  OS: Operating System  VERIFYSIGNATURE: The OS operation or API being called

61 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_VERIFYSIGNATURE  PREEMPTIVE: Non-yielding  OS: Operating System  VERIFYSIGNATURE: The OS operation or API being called  Let’s Look it Up

62 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_VERIFYSIGNATURE  PREEMPTIVE: Non-yielding  OS: Operating System  VERIFYSIGNATURE: The OS operation or API being called  Verifies if a digital signature matches the signature used to encrypt data

63 Diagnosing Performance with Wait Statistics  PREEMPTIVE_OS_VERIFYSIGNATURE  PREEMPTIVE: Non-yielding  OS: Operating System  VERIFYSIGNATURE: The OS operation or API being called  Let’s Look it Up

64 Diagnosing Performance with Wait Statistics  Troubleshooting Slow Queries

65 Diagnosing Performance with Wait Statistics  Resources  http://www.sqlsoldier.com/wp/tag/performance- optimization http://www.sqlsoldier.com/wp/tag/performance- optimization  http://www.sqlsoldier.com/wp/tag/troubleshooting http://www.sqlsoldier.com/wp/tag/troubleshooting  http://sqlserverperformance.wordpress.com/?s=DMV http://sqlserverperformance.wordpress.com/?s=DMV  http://sqlloadgenerator.codeplex.com http://sqlloadgenerator.codeplex.com

66 Diagnosing Performance with Wait Statistics

67 Thanks! Thank you for coming!  My blog: www.sqlsoldier.comwww.sqlsoldier.com  Twitter: twitter.com/SQLSoldiertwitter.com/SQLSoldier  Engage me on your project: www.DBBest.comwww.DBBest.com


Download ppt "Diagnosing Performance with Wait Statistics Robert L Davis Principal Database"

Similar presentations


Ads by Google