Presentation is loading. Please wait.

Presentation is loading. Please wait.

Root Cause Analysis with DMVs

Similar presentations


Presentation on theme: "Root Cause Analysis with DMVs"— Presentation transcript:

1 Root Cause Analysis with DMVs
Using DMVs to gather performance data from SQL Server

2 Intro Introduced with SQL Server 2005
First method for gathering data on SQL Server performance Advantages: Allows us to gather information quickly Data is gathered passively by SQL Server Disadvantages: Piecemeal information; does not provide us with a complete data set to review afterward

3 Query Execution Stats Review resource usage by cached plans
sys.dm_exec_query_stats sys.dm_exec_query_plan sys.dm_exec_sql_text Statistics can reach back to last restart

4 sys.dm_exec_query_stats
Contains performance data on cached plans Logical\physical reads, CPU, executions, duration 2016: adding threads and memory grants Data relates to statements, not batch Provides sql_handle and plan_handle Caveat: Only provides details on cached plans Restarting SQL Server, flushing the cache empties this

5 sys.dm_exec_query_plan(plan_handle)
Returns the XML plan Plan_handle provided by sys.dm_exec_query_stats Sys.dm_exec_cached_plans Sys.dm_exec_requests Same caveats as sys.dm_exec_query_stats See also sys.dm_exec_text_query_plan

6 sys.dm_exec_sql_text (sql_handle | plan_handle)
Provides the TSQL for a batch Keeps whitespace and comments Too long? Copy\paste to another session

7 Waits and Status Waits are key to understanding performance issues
Review whether queries are waiting, blocked, or active Check status of the connection sys.dm_os_wait_stats sys.dm_exec_requests sys.dm_exec_sessions sys.dm_exec_connections sys.dm_os_waiting_tasks

8 sys.dm_os_wait_stats Key point to understanding SQL Server performance
Running total of all waits Resets on restart Can be manually reset: DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR); Need two samples to see changes Ignore background noise

9 sys.dm_exec_requests Includes information about each active query\command on SQL Server Wait types, wait resources, and duration CPU, reads, and writes Memory Allocation and Command type ANSI connection settings and login details Provides sql_handle, plan_handle, and request_id Only provides details on parent thread

10 sys.dm_exec_sessions Returns information about all open sessions
Including those not running a query currently Overlaps some details with sys.dm_exec_requests Performance details relate to the connection, not current query Provides client application details (host_name, program_name)

11 sys.dm_exec_connections
1-to-1 relationship with sys.dm_exec_sessions Excludes system sessions Connection_id relates to sys.dm_exec_sessions sys.dm_exec_requests Provides client_net_address, most_recent_sql_handle

12 sys.dm_os_waiting_tasks
Provides information on all threads that are waiting or blocking More useful for parallel queries sys.dm_exec_requests only provides the parent request Task_address relates to other OS DMVs Detailed information on resource_description:

13 Memory Usage Quick approaches for identifying issues
Frequently indicated in Errorlog Max Server Memory limits buffer pool Buffer Pool typically largest consumer Consider other applications on the system

14 sys.dm_os_memory_clerks
Currently active memory clerks Details not query specific Use to determine larger trends in memory Aggregate by type: MEMORYCLERK_SQLBUFFERPOOL typically largest

15 sys.dm_os_memory_objects
Returns information on all currently allocated memory objects More granular than sys.dm_os_memory_clerks Can be grouped and aggregated by type Multiple counters for various memory allocations Can relate to other tables by memory_object_address or page_allocator_address

16 sys.dm_exec_cached_plans
One entry for each currently cached plan Shows the memory allocation for the plan object itself Provides a usecount and refcount for each and the plan_handle optimize for ad hoc workloads? Can breakdown memory objects by type

17 sys.dm_exec_query_memory_grants
Returns details about all queries that have requested memory Granted and waiting (grant_time IS NULL) Identify queries waiting on memory and requested amounts Identify granted requests consuming large amounts of memory Links by plan_handle, sql_handle, request_id, session_id Has DOP and Cost information

18 IO Statistics Common performance bottleneck
Expect a read\write to take <=10ms, on average Need a way to confirm wait types Source of storage issue: Overloaded Underperforming

19 sys.dm_io_virtual_file_stats (database_id, file_id)
Provides details on activity on the specified file Total reads and writes, IO waits (ms) Pass NULL parameters to see all files Calculate delay per read or write Numbers reset on restart See relative IO activity within SQL

20 sys.dm_io_pending_io_requests
Provides details on pending IO requests Requests waiting at the OS or SOS level Can be related to schedulers (CPU) Can indicate if IO is impacting a scheduler io_pending_ms_ticks provides a duration for pending operations Could indicate storage a bottleneck Dirty reads are possible; numbers may be inaccurate

21 In summary, Each DMV exposes different parts of SQL Server’s activity
This list is not exhaustive Data can be gathered and reviewed very quickly No logs for this data Unless you create code to write this to a permanent table Many DMVs are more useful in conjunction

22 Questions @SQLJared


Download ppt "Root Cause Analysis with DMVs"

Similar presentations


Ads by Google