Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hilary Cotter Extended Events.

Similar presentations


Presentation on theme: "Hilary Cotter Extended Events."— Presentation transcript:

1 Hilary Cotter Extended Events

2 Clients

3 Agenda What are Extended Events? How do they compare with Profiler Concepts Tutorial Use cases

4 What are Extended Events
Real-time data capture No performance penalty Lightweight Lock:Aquired, Lock:Released with little performance degradation. Based on Event Tracing for Windows (ETW) Allows integration with OS operations, for example we can now trace if a file copy operation is degrading performance on SQL Server. Full programmability support TSQL SMO PowerShell

5 How do they compare with Profiler
XE Designed to replace Profiler/SQL Trace XE Captures more value/properties/events than profiler XE is integrated with ETW and Management Studio Activity Monitor XE does not require a connection to SQL Server SQL Trace will be deprecated in SQL Next (still ships in SQL 2017) SQL 2008 – no nice interface for Extended Events Extended Events Manager - SQL 2012 baked into Management Studio Allows you to obtain wait statistics on a query/proc/statement.

6 ETW

7 ETW Logman query providers c:\temp\out.txt Select * from sys.dm_xe_packages Package0 60AA9FBF-673B-4553-B7ED-71DCA7F5E972 Sqlos BD97CC63-3F AA93-607BD12E78B2 XeDkPkg 52FC232C-03D5-4E1F-A6BF-BBC66FE20E6A sqlserver 655FD93F D5-B2BA-330F7FFB6491 SecAudit F235752A-D5C0-4C9A-A735-9C3B6F6E43B1 ucs C0AB75C5-B1EA-445B-B7DF-F897686F94E7 sqlclr 1E99FE90-A4FE-45E6-9DFD-A45041F02314 filestream B086C2F B119-D80B5362B5CA sqlserver 03FDA7D0-91BA-45F B6DD0B8E9F2

8 Traces vs XE

9 Well what about the black box trace then?
SQL 2012 adds default xe sessions (traces) AlwaysOn_Health System_health SQL 2014 adds Nothing SQL 2016 adds Telemetry_xevents Mainly for diagnostics – error collection

10 Ring buffer Getting ahead of ourselves but… SELECT * FROM sys.dm_os_ring_buffers RING_BUFFER_CLRAPPDOMAIN RING_BUFFER_CONNECTIVITY RING_BUFFER_EXCEPTION RING_BUFFER_HOBT_SCHEMAMGR RING_BUFFER_MEMORY_BROKER RING_BUFFER_MEMORY_BROKER_CLERKS RING_BUFFER_RESOURCE_MONITOR RING_BUFFER_SCHEDULER RING_BUFFER_SCHEDULER_MONITOR RING_BUFFER_SECURITY_ERROR RING_BUFFER_XE_BUFFER_STATE RING_BUFFER_XE_LOG

11 Extended Events Object Model
Packages Events Actions Predicates Targets Types Maps Channels

12 XE - packages select * from sys.dm_xe_packages where coalesce(capabilities,1)=1 sqlos Extended events for SQL Operating System sqlserver Extended events for Microsoft SQL Server SecAudit Security Audit Events ucs Extended events for Unified Communications Stack sqlclr Extended events for SQL CLR filestream Extended events for SQL Server FILESTREAM and FileTable qds Extended events for Query Store XtpRuntime Extended events for the XTP Runtime XtpCompile Extended events for the XTP Compile XtpEngine Extended events for the XTP Engine XTP (eXtreme Transaction Processing – Hekaton). sqlserver

13 XE- Events Well known endpoints in SQL Server Code, ie sp_statement_completed, rpc_starting, rpc_completed. Events are categorized in ETW as Admin – error reports, deprecated events, blocks, deadlocks Analytical – this is of most interest to us. Debug – css primarily. Operational – managing admin events – attaching dbs, dropping dbs. Blocked Process Report.

14 XE-Actions Capability to execute additional actions when the event fires within the engine. Think of these like the columns in Profiler

15 XE-Predicates Allow you to filter on certain events. Source – and Compare

16 XE-types and maps Select * from sys.dm_xe_objects where object_type in ('type','map') type scalar Map – list Select * from sys.dm_xe_objects where object_type in ('type','map') and name='wait_types' Select * from sys.dm_xe_map_values where name='wait_types'

17 XE-Target Where data ends up etw_classic_sync_target-Event Tracing for Windows (ETW) Synchronous Target Histogram-Use the histogram target to aggregate event data based on a specific event data field or action associated with the event. The histogram allows you to analyze distribution of the event data over the period of the event session. event_file-Use the event_file target to save the event data to an XEL file, which can be archived and used for later analysis and review. You can merge multiple XEL files to view the combined data from separate event sessions. pair_matching-Pairing target event_counter-Use the event_counter target to count the number of occurrences of each event in the event session. ring_buffer-Asynchronous ring buffer target.

18 XE Templates – locks and blocks
Count Query Locks Use this template to identify the most lock intensive queries for investigation and tuning.

19 XE Templates – Query Execution
Query Batch Sampling Samples 20% (by default) of your batches and RPC statements in your workload and error information. Query Batch Tracking Collects all batch and RPC level statements as well as error information. Can be very large. Query Detail Sampling Samples 20% (by default) of your statements in your workload and error information. Collects the query hash and query plan hash for every statement it tracks. Query Detail Tracking Collects all detailed statement and error information. Can be used to determine which statement in a batch or procedure threw the error. Can be very large. Query Wait Statistics Tracks internal and external wait statistics for individual query statements, batches and RPCs. 20 % sample rate.

20 XE Templates - System Monitoring
Activity Tracking Most similar to trace. Connection Monitoring Tracks connection activity for a server. Normal connection activity is tracked using the login and logout events, and problems are recorded using the connectivity_ring_buffer_recorded event. Database Log File IO Tracking Monitors the IO for database log files on a server by tracking asynchronous IO, database log flushes, file writes, spinlock backoffs of type LOGFLUSHQ and waits of type WRITELOG.

21 Top Resource Consumers
High Performance.SQL Master database on publisher, table called called Perf

22 Timeouts Timeouts1.sql

23 Page Splits PageSplits.sql

24 Errors Errors.sql

25 Converting a profiler trace to XE
From C:\ExtendedEvents\Converting my SQL Server Trace File to an Extended Event

26 Blocking

27 Debugging use master GO insert into dm_hadr_database_replica_states select recovery_lsn, truncation_lsn, last_hardened_lsn, last_received_lsn, log_send_queue_size,log_send_queue_size/log_send_rate[log_send_queue_size/log_send_rate],log_send_rate,redo_queue_size, last_redone_lsn, last_redone_time,database_id, getdate() dtstamp, db_name(database_id) databaseName from sys.dm_hadr_database_replica_states where log_send_rate>0


Download ppt "Hilary Cotter Extended Events."

Similar presentations


Ads by Google