Sunteți pe pagina 1din 24

Module 9

Extended Events
Module Overview

• Extended Events Core Concepts


• Working with Extended Events
Lesson 1: Extended Events Core Concepts

• Extended Events, SQL Trace, and SQL Server Profiler


• Extended Events Architecture
• Packages
• Events
• Predicates
• Actions
• Targets
• Sessions
• Types and Maps
• Demonstration: Creating an Extended Events Session
Extended Events, SQL Trace, and SQL Server Profiler

• SQL Trace and SQL Server Profiler are tools for


collecting trace information about activity on an
SQL Server instance
• Extended Events is the successor to SQL Trace
and will eventually replace it completely
• SQL Trace/SQL Server Profiler has been marked for
deprecation since SQL Server 2012
• Extended Events is more flexible than SQL Trace
• Support for new features added since SQL Server 2012
• Greater flexibility comes with greater complexity
Extended Events Architecture

• Extended Events engine provides capabilities


• User defines session
• Session collects event
• Event triggers action
• Event is filtered by predicate
• Session writes to target
• A package defines the objects available to a
session
Packages

• Executables and executable modules expose


Extended Events packages
• A package is a container for other object types:
• Events
• Predicates
• Actions
• Targets
• Maps
• Types
Events

• Events are logging points in executable code


• When an event fires, it indicates that the associated
code has been executed
• Returns data in a fixed schema
• Events are compatible with Event Tracing for Windows
Predicates

• Allow the construction of rules to filter event


capture
• Made up of two subcategories:
• Comparisons. Logical operators (=, <, > and so on)
• Sources. Values that may be used as inputs to comparisons
• Complex predicates may be constructed; every n
events, or every n seconds
Actions

• Actions provide supplementary information


about an event
• Each event may be linked to one or more actions
• Actions are triggered synchronously after an associated
event has fired
Targets

• Targets collect data from Extended Events


sessions
• A session may write to multiple targets
• Targets may be synchronous or asynchronous
• Event counter: synchronous
• Event file: asynchronous
• Event pairing: asynchronous
• Event Tracing for Windows: synchronous
• Histogram: asynchronous
• Ring buffer: asynchronous
• An event will only be written once to a target
Sessions

• A session links events to targets


• Events may include actions
• Events may be filtered with predicates
• Sessions are isolated from one another
• A session has a state (started or stopped)
• A session has a buffer to hold event data as it is
captured
Types and Maps

• Types
• Data type definitions for Extended Events data
• Maps
• Lookup tables to convert integer values to text values
Demonstration: Creating an Extended Events Session

• In this demonstration, you will see how to create


an Extended Events session
Lesson 2: Working with Extended Events

• Configuring Sessions
• Configuring Targets
• The system_health Extended Events Session
• Usage Scenarios for Extended Events
• Extended Events Best Practices
• Demonstration: Tracking Session-Level Waits
Configuring Sessions

• Session configuration options:


• MAX_MEMORY
• EVENT_RETENTION_MODE
• MAX_DISPATCH_LATENCY
• MAX_EVENT_SIZE
• MEMORY_PARTITION_MODE
• STARTUP_STATE
• TRACK_CAUSALITY
Configuring Targets

• Event File
• Event Pairing
• Ring Buffer
• Histogram
• Event Tracing for Windows

• Event Counter
• Takes no configuration
The system_health Extended Events Session

• Created by default on all instances of SQL Server


2008 or later versions
• Starts at instance startup
• Captures events useful for troubleshooting
• Ring buffer and file targets
Usage Scenarios for Extended Events
Extended Events Best Practices

• Run Extended Events sessions only when you


need them
• Use the SSMS GUI to browse available events
• Understand the limitations of the ring buffer
target
• Consider the performance impact of collecting
query execution plans
• Understand the deadlock graph format
Demonstration: Tracking Session-Level Waits

• In this demonstration, you will see how to report


on wait types by session using Extended Events
Lab: Extended Events

• Exercise 1: Using the system_health Extended


Events Session
• Exercise 2: Tracking Page Splits Using Extended
Events

Logon Information
Virtual machine: 10987C-MIA-SQL
User name: ADVENTUREWORKS\Student
Password: Pa55w.rd

Estimated Time: 90 minutes


Lab Scenario

While investigating why the new SQL Server


instance was so slow, you came across deadlock
occurrences and excessive fragmentation in
indexes caused by page split operations. In this
lab, you will review deadlock occurrences using
the default session and implement a new
Extended Event session to identify workloads that
cause huge page splits.
Lab Review

In this lab, you have learned how to:


• Use the system_health Extended Events session.
• Create your own Extended Events session.
Module Review and Takeaways

In this module, you have learned about the


Extended Events system and its components. You
have learned about the objects that comprise an
Extended Events session, and how to query the
metadata about each object type to understand the
information it provides.
You have learned how to create, amend and drop
Extended Events sessions using either SSMS or
Transact-SQL, in addition to learning about various
methods for extracting data from session targets.

S-ar putea să vă placă și