SlideShare a Scribd company logo
1 of 40
Extended Events
Practical Examples
Dean Richards
Who Am I
• 20+ years of experience in SQL Server and Oracle
• Speak at many user groups throughout US
• Owner of DRConsulting
• Dean.Richards@databaseperformance.guru
• @ConfioDean
• Focus on application and database performance
• Review performance for hundreds of customers per year
• Common question – how do I do performance tuning?
Agenda
• Extended Events Introduction
• Terms & Useful DMVs
• How to Create Sessions
• Viewing & Reporting Event Info
• Examples
• Deadlock Monitoring
• Query Performance and Waits
• Actual Execution Plans
Extended Events Introduction
• Lightweight event-handling mechanism
• Captures event information like SQL Profiler / SQL Trace
• More information plus you can now configure easier
• When events are triggered
• They can be sent to a target for further analysis
• Introduced in SQL Server 2008
• Very complex to code and read (parse xml)
• Much Improved in 2012 with many more Events
GUI for XE
• SQL 2012+ has a GUI included in SSMS
• SQL 2008 does not
• Get one from http://extendedeventmanager.codeplex.com/
• Much easier, makes XE usable in SQL 2008
5
Key Terms
• Session – collection of events with actions and targets
• Package – can be sqlserver objects or sqlos objects
• Event – an instrumented piece of code within SQL Server
or Windows O/S, e.g. sql_statement_completed
• Action – what should be done when an event fires, e.g.
collect T-SQL code, wait information, plans
• Target – a place to store the event data, e.g. ring buffer in
memory and file in O/S
• Predicates – allows selective collection of events, e.g. do
not capture system process information
DDL for XE
• 2008 - DDL statements that create / modify Extended Events
sessions
• CREATE EVENT SESSION
• Creates an extended event session object
• Identifies Source of the events, Targets, and Parameters
• ALTER EVENT SESSION
• Starts/stops an event session or changes an event session
configuration
• DROP EVENT SESSION
• Drops an event session
• DMVs / Catalog views show session data & metadata
• Use TSQL statements to get information on every extended events
session that is created
Creation Session DDL Example
CREATE EVENT SESSION [Deadlocks] ON SERVER
ADD EVENT sqlserver.xml_deadlock_report(
ACTION(sqlserver.client_app_name,sqlserver.client_hostname,s
qlserver.database_id,sqlserver.session_id,sqlserver.sql_text,sqls
erver.tsql_stack,sqlserver.username))
ADD TARGET package0.event_file(SET
filename=N'C:tempdeadlocks.xel',max_file_size=(10))
WITH (MAX_MEMORY=4096
KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,M
AX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0
KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,
STARTUP_STATE=OFF)
GO
Catalog Views for XE
• sys.server_event_sessions – session definitions
• sys.server_event_session_events – events to collect
• sys.server_event_session_actions – actions to collect
• sys.server_event_session_fields – list of data to collect
• sys.server_event_session_targets – where to store the
collected data
DMVs for XE
• sys.dm_xe_sessions – session that have been created
• sys.dm_xe_session_events
• sys.dm_xe_session_event_actions
• sys.dm_xe_session_object_columns
• sys.dm_xe_session_targets
GUI Walkthrough
• To create a new session can use either a wizard manually
go through screens
system_health Session
• Default session used to collect deadlocks, waits, errors
and other information
• Started by Default
• Collects 17 Events into Ring Buffer
• Suggest Adding File Target
• Do not modify, instead create other sessions to
customize events and actions
system_health General
system_health Events – Select
List of All
Events
Chosen
Events
system_health Events – Configure
Chosen
Events Event
Options
system_health Events – Predicates
Chosen
Events Filters or
Predicates
system_health Targets
Targets
system_health Advanced
Data Loss
Write to File
after 2 min or
4MB in
memory
system_health View Data
system_health View Data
system_health Filter Data
system_health Data Details
Deadlock Monitoring
with system_health Session
system_health Deadlock Graph
• The system_health session monitors deadlocks by default
• Can use it to see deadlock graph
Collecting SQL Statement and Wait
With Custom Session
XE Session for SQLs and Waits
• Fields defined the default data to collect when the
highlighted event fires
• These change based on the highlighted event
XE Session – Global Fields
• Events of when a SQL (sproc or adhoc) or wait (internal
or external) completes
• Global Fields tab defines the optional data that gets
collected when the event fires
XE Session – Filters
• Define the sessions to watch
• Do not collect SPIDs doing something in system databases
• Do not collect data for background sessions
• Collect for 1 out of 5 sessions to reduce load on SQL Server
• Collect if the duration is >= 0.1 seconds
XE Session – Data Storage
• File – longer term storage of data
• Specify where to store them, how large and retention
• Can query it using sys.fn_xe_file_target_read_file
• Ring Buffer – shorter term storage in memory
XE Session – Starting
• Can manually start when needed
• Also an option to start automatically when instance starts
• Can export a script for creation on other instances
• Modify it with Properties option
Response Time Analysis
• Now that we have data, what do we do with it?
• Can analyze from Management Studio
• Right-Click on the file output and use View Target Data
Analysis – Sort, Group, Modify
• Left click on any column to sort
• Right click on columns to group and aggregate
• For example, right click on query_hash and group by it
• Right click on duration column and sum it by query_hash
• Can also add/remove columns to display
Analysis - Filtering
• Having problems with a specific application or database
• Filter the response time data by those columns
• Can also filter by a point in time when problem was occurring
Analysis - Filtering
Filter by a
point in time
Filter by any
collected value
Capturing Actual Plans
Capture Actual Plan
• Use query_post_execution_showplan event
• Collect the SQL text action as well
• It collects actual plan information immediately after a
SQL executes
• Much like SSMS actual plan collection
XE Event Configuration
Showing the Actual Plan
• Note the Actual
Number of Rows along
with Estimated Rows
• This allows us to know
which plan was really
used for a query
Analysis - Queries
• Can also analyze the data by using XML queries
• Read data from the XE files using
sys.fn_xe_file_target_read_file
• Many queries on the web, but my favorite is from
Jeremiah Peschka on brentozar.com
• If you are using Ring Buffer output, can also query
against that
• Data is aged out much quicker
• There are limitations as noted by Jonathan Keyhais on
sqlskills.com
Summary
• Extended Events are light weight
• Quickly / continuously gather information
• 2012+ - Easy to capture, store and view data
• Via Sessions, Events, Actions, Filters, & Targets
• Can be used to troubleshoot issues
• Replaces Profiler
• Deprecated???
• Still need to use for Trace Capture of Analysis Services
• Replaces SQL Trace
• Stored procedures, functions and catalog views

More Related Content

What's hot

SQL Server Integration Services
SQL Server Integration ServicesSQL Server Integration Services
SQL Server Integration ServicesRobert MacLean
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Mydbops
 
[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기NHN FORWARD
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLMorgan Tocker
 
1.mysql disk io 모니터링 및 분석사례
1.mysql disk io 모니터링 및 분석사례1.mysql disk io 모니터링 및 분석사례
1.mysql disk io 모니터링 및 분석사례I Goo Lee
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기NeoClova
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxNeoClova
 
Free Load Testing Tools for Oracle Database – Which One Do I Use?
Free Load Testing Tools for Oracle Database – Which One Do I Use?Free Load Testing Tools for Oracle Database – Which One Do I Use?
Free Load Testing Tools for Oracle Database – Which One Do I Use?Christian Antognini
 
Zabbix Performance Tuning
Zabbix Performance TuningZabbix Performance Tuning
Zabbix Performance TuningRicardo Santos
 
Data Warehouse on Kubernetes: lessons from Clickhouse Operator
Data Warehouse on Kubernetes: lessons from Clickhouse OperatorData Warehouse on Kubernetes: lessons from Clickhouse Operator
Data Warehouse on Kubernetes: lessons from Clickhouse OperatorAltinity Ltd
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability Mydbops
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용I Goo Lee
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuningguest5ca94b
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLRené Cannaò
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline► Supreme Mandal ◄
 
Always on in SQL Server 2012
Always on in SQL Server 2012Always on in SQL Server 2012
Always on in SQL Server 2012Fadi Abdulwahab
 
Giải pháp always on trong sql server 2012
Giải pháp always on trong sql server 2012Giải pháp always on trong sql server 2012
Giải pháp always on trong sql server 2012laonap166
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterKenny Gryp
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 

What's hot (20)

SQL Server Integration Services
SQL Server Integration ServicesSQL Server Integration Services
SQL Server Integration Services
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
 
[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQL
 
1.mysql disk io 모니터링 및 분석사례
1.mysql disk io 모니터링 및 분석사례1.mysql disk io 모니터링 및 분석사례
1.mysql disk io 모니터링 및 분석사례
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
 
Free Load Testing Tools for Oracle Database – Which One Do I Use?
Free Load Testing Tools for Oracle Database – Which One Do I Use?Free Load Testing Tools for Oracle Database – Which One Do I Use?
Free Load Testing Tools for Oracle Database – Which One Do I Use?
 
Introduction to weblogic
Introduction to weblogicIntroduction to weblogic
Introduction to weblogic
 
Zabbix Performance Tuning
Zabbix Performance TuningZabbix Performance Tuning
Zabbix Performance Tuning
 
Data Warehouse on Kubernetes: lessons from Clickhouse Operator
Data Warehouse on Kubernetes: lessons from Clickhouse OperatorData Warehouse on Kubernetes: lessons from Clickhouse Operator
Data Warehouse on Kubernetes: lessons from Clickhouse Operator
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuning
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline
 
Always on in SQL Server 2012
Always on in SQL Server 2012Always on in SQL Server 2012
Always on in SQL Server 2012
 
Giải pháp always on trong sql server 2012
Giải pháp always on trong sql server 2012Giải pháp always on trong sql server 2012
Giải pháp always on trong sql server 2012
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 

Similar to Practical examples of using extended events

SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1sqlserver.co.il
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts
 
SQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowSQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowDean Richards
 
Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverAntonios Chatzipavlis
 
PASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and BaseliningPASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and BaseliningPARIKSHIT SAVJANI
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsZohar Elkayam
 
Sql server-performance-hafi
Sql server-performance-hafiSql server-performance-hafi
Sql server-performance-hafizabi-babi
 
Day 7 - Make it Fast
Day 7 - Make it FastDay 7 - Make it Fast
Day 7 - Make it FastBarry Jones
 
An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)Marco Gralike
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1SolarWinds
 
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended EventsSQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Eventssqlserver.co.il
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting forJason Strate
 
SQL Server 2008 For Developers
SQL Server 2008 For DevelopersSQL Server 2008 For Developers
SQL Server 2008 For DevelopersJohn Sterrett
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!Aaron King
 
Collaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR ReportCollaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR ReportAlfredo Krieg
 

Similar to Practical examples of using extended events (20)

SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New Features
 
SQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowSQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should Know
 
Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql server
 
PASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and BaseliningPASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and Baselining
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
 
Sql server-performance-hafi
Sql server-performance-hafiSql server-performance-hafi
Sql server-performance-hafi
 
Day 7 - Make it Fast
Day 7 - Make it FastDay 7 - Make it Fast
Day 7 - Make it Fast
 
An AMIS overview of database 12c
An AMIS overview of database 12cAn AMIS overview of database 12c
An AMIS overview of database 12c
 
An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
 
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended EventsSQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
 
SQL Server 2008 For Developers
SQL Server 2008 For DevelopersSQL Server 2008 For Developers
SQL Server 2008 For Developers
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
Oracle DBA
Oracle DBAOracle DBA
Oracle DBA
 
A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!
 
Chapter 11new
Chapter 11newChapter 11new
Chapter 11new
 
Collaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR ReportCollaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR Report
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Practical examples of using extended events

  • 2. Who Am I • 20+ years of experience in SQL Server and Oracle • Speak at many user groups throughout US • Owner of DRConsulting • Dean.Richards@databaseperformance.guru • @ConfioDean • Focus on application and database performance • Review performance for hundreds of customers per year • Common question – how do I do performance tuning?
  • 3. Agenda • Extended Events Introduction • Terms & Useful DMVs • How to Create Sessions • Viewing & Reporting Event Info • Examples • Deadlock Monitoring • Query Performance and Waits • Actual Execution Plans
  • 4. Extended Events Introduction • Lightweight event-handling mechanism • Captures event information like SQL Profiler / SQL Trace • More information plus you can now configure easier • When events are triggered • They can be sent to a target for further analysis • Introduced in SQL Server 2008 • Very complex to code and read (parse xml) • Much Improved in 2012 with many more Events
  • 5. GUI for XE • SQL 2012+ has a GUI included in SSMS • SQL 2008 does not • Get one from http://extendedeventmanager.codeplex.com/ • Much easier, makes XE usable in SQL 2008 5
  • 6. Key Terms • Session – collection of events with actions and targets • Package – can be sqlserver objects or sqlos objects • Event – an instrumented piece of code within SQL Server or Windows O/S, e.g. sql_statement_completed • Action – what should be done when an event fires, e.g. collect T-SQL code, wait information, plans • Target – a place to store the event data, e.g. ring buffer in memory and file in O/S • Predicates – allows selective collection of events, e.g. do not capture system process information
  • 7. DDL for XE • 2008 - DDL statements that create / modify Extended Events sessions • CREATE EVENT SESSION • Creates an extended event session object • Identifies Source of the events, Targets, and Parameters • ALTER EVENT SESSION • Starts/stops an event session or changes an event session configuration • DROP EVENT SESSION • Drops an event session • DMVs / Catalog views show session data & metadata • Use TSQL statements to get information on every extended events session that is created
  • 8. Creation Session DDL Example CREATE EVENT SESSION [Deadlocks] ON SERVER ADD EVENT sqlserver.xml_deadlock_report( ACTION(sqlserver.client_app_name,sqlserver.client_hostname,s qlserver.database_id,sqlserver.session_id,sqlserver.sql_text,sqls erver.tsql_stack,sqlserver.username)) ADD TARGET package0.event_file(SET filename=N'C:tempdeadlocks.xel',max_file_size=(10)) WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,M AX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF, STARTUP_STATE=OFF) GO
  • 9. Catalog Views for XE • sys.server_event_sessions – session definitions • sys.server_event_session_events – events to collect • sys.server_event_session_actions – actions to collect • sys.server_event_session_fields – list of data to collect • sys.server_event_session_targets – where to store the collected data
  • 10. DMVs for XE • sys.dm_xe_sessions – session that have been created • sys.dm_xe_session_events • sys.dm_xe_session_event_actions • sys.dm_xe_session_object_columns • sys.dm_xe_session_targets
  • 11. GUI Walkthrough • To create a new session can use either a wizard manually go through screens
  • 12. system_health Session • Default session used to collect deadlocks, waits, errors and other information • Started by Default • Collects 17 Events into Ring Buffer • Suggest Adding File Target • Do not modify, instead create other sessions to customize events and actions
  • 14. system_health Events – Select List of All Events Chosen Events
  • 15. system_health Events – Configure Chosen Events Event Options
  • 16. system_health Events – Predicates Chosen Events Filters or Predicates
  • 18. system_health Advanced Data Loss Write to File after 2 min or 4MB in memory
  • 24. system_health Deadlock Graph • The system_health session monitors deadlocks by default • Can use it to see deadlock graph
  • 25. Collecting SQL Statement and Wait With Custom Session
  • 26. XE Session for SQLs and Waits • Fields defined the default data to collect when the highlighted event fires • These change based on the highlighted event
  • 27. XE Session – Global Fields • Events of when a SQL (sproc or adhoc) or wait (internal or external) completes • Global Fields tab defines the optional data that gets collected when the event fires
  • 28. XE Session – Filters • Define the sessions to watch • Do not collect SPIDs doing something in system databases • Do not collect data for background sessions • Collect for 1 out of 5 sessions to reduce load on SQL Server • Collect if the duration is >= 0.1 seconds
  • 29. XE Session – Data Storage • File – longer term storage of data • Specify where to store them, how large and retention • Can query it using sys.fn_xe_file_target_read_file • Ring Buffer – shorter term storage in memory
  • 30. XE Session – Starting • Can manually start when needed • Also an option to start automatically when instance starts • Can export a script for creation on other instances • Modify it with Properties option
  • 31. Response Time Analysis • Now that we have data, what do we do with it? • Can analyze from Management Studio • Right-Click on the file output and use View Target Data
  • 32. Analysis – Sort, Group, Modify • Left click on any column to sort • Right click on columns to group and aggregate • For example, right click on query_hash and group by it • Right click on duration column and sum it by query_hash • Can also add/remove columns to display
  • 33. Analysis - Filtering • Having problems with a specific application or database • Filter the response time data by those columns • Can also filter by a point in time when problem was occurring
  • 34. Analysis - Filtering Filter by a point in time Filter by any collected value
  • 36. Capture Actual Plan • Use query_post_execution_showplan event • Collect the SQL text action as well • It collects actual plan information immediately after a SQL executes • Much like SSMS actual plan collection
  • 38. Showing the Actual Plan • Note the Actual Number of Rows along with Estimated Rows • This allows us to know which plan was really used for a query
  • 39. Analysis - Queries • Can also analyze the data by using XML queries • Read data from the XE files using sys.fn_xe_file_target_read_file • Many queries on the web, but my favorite is from Jeremiah Peschka on brentozar.com • If you are using Ring Buffer output, can also query against that • Data is aged out much quicker • There are limitations as noted by Jonathan Keyhais on sqlskills.com
  • 40. Summary • Extended Events are light weight • Quickly / continuously gather information • 2012+ - Easy to capture, store and view data • Via Sessions, Events, Actions, Filters, & Targets • Can be used to troubleshoot issues • Replaces Profiler • Deprecated??? • Still need to use for Trace Capture of Analysis Services • Replaces SQL Trace • Stored procedures, functions and catalog views

Editor's Notes

  1. Full link to Jeremiah’s blog on this subject with queries you can use: http://www.brentozar.com/archive/2014/04/collecting-detailed-performance-measurements-extended-events/ Full link to Jonathan Keyhais article on ring buffer issues https://www.sqlskills.com/blogs/jonathan/why-i-hate-the-ring_buffer-target-in-extended-events/