Presentation is loading. Please wait.

Presentation is loading. Please wait.

Extended Events Hilary.cotter@gmail.com.

Similar presentations


Presentation on theme: "Extended Events Hilary.cotter@gmail.com."— Presentation transcript:

1 Extended Events

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

3 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

4 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.

5 ETW

6 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

7 Traces vs XE

8 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

9 Ring buffer Getting ahead of ourselves but…

10 Extended Events Object Model
Module Package(s) Events Targets Actions Types Predicates Maps Channels

11 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

12 Extended Events Object Model
Module Package(s) Events Targets Actions Types Predicates Maps Channels Packages Events and Actions Filters and Predicates Sessions Targets

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 Extended Events Object Model
Module Package(s) Events Targets Actions Types Predicates Maps Channels Packages Events and Actions Filters and Predicates Sessions Targets

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

16 Extended Events Object Model
Module Package(s) Events Targets Actions Types Predicates Maps Channels Packages Events and Actions Filters and Predicates Sessions Targets

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

18 Extended Events Object Model
Module Package(s) Events Targets Actions Types Predicates Maps Channels Packages Events and Actions Filters and Predicates Sessions Targets

19 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'

20 Extended Events Object Model
Module Package(s) Events Targets Actions Types Predicates Maps Channels Packages Events and Actions Filters and Predicates Sessions Targets

21 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.

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

23 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.

24 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.

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

26 Timeouts Timeouts1.sql

27 Page Splits PageSplits.sql
pages-splits-in-sql-server-2012-extended-events-no-really-this-time/

28 Errors Errors.sql

29 Converting a profiler trace to XE
From grating-from-sql-trace-to-extended-events.aspx C:\ExtendedEvents\Converting my SQL Server Trace File to an Extended Event

30 Blocking

31 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_q ueue_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 "Extended Events Hilary.cotter@gmail.com."

Similar presentations


Ads by Google