18
CHAPTER Using Extended Events for Troubleshooting SQL Server Antonios Chatzipavlis SQLschool.gr Founder, Principal Consultant SQL Server Evangelist, MVP on SQL Server June 4, 2015

Using extended events for troubleshooting sql server

Embed Size (px)

Citation preview

Page 1: Using extended events for troubleshooting sql server

CHAPTER

Using Extended Events

for Troubleshooting

SQL ServerAntonios ChatzipavlisSQLschool.gr Founder, Principal Consultant

SQL Server Evangelist, MVP on SQL Server

June 4, 2015

Page 2: Using extended events for troubleshooting sql server

I have been started with computers.

I started my professional carrier in computers industry.

I have been started to work with SQL Server version 6.0

I earned my first certification at Microsoft as Microsoft Certified Solution

Developer (3rd in Greece) and started my carrier as Microsoft Certified

Trainer (MCT) with more than 20.000 hours of training until now!

I became for first time Microsoft MVP on SQL Server

I created the SQL School Greece (www.sqlschool.gr)

I became MCT Regional Lead by Microsoft Learning Program.

I was certified as MCSE : Data Platform, MCSE: Business Intelligence

Antonios ChatzipavlisDatabase Archi tect

SQL Server Evange l i st

MCT, MCSE, MCITP, MCPD, MCSD, MCDBA,

MCSA, MCTS, MCAD, MCP, OCA, ITIL-F

1982

1988

1996

1998

2010

2012

2013

CHAPTER

Page 3: Using extended events for troubleshooting sql server

Follow us in social media

Twitter @antoniosch / @sqlschool

Facebook fb/sqlschoolgr

YouTube yt/user/achatzipavlis

LinkedIn SQL School Greece group

Pinterest pi/SQLschool/

Page 5: Using extended events for troubleshooting sql server

Extended Events was introduced in

SQL Server 2008 as a new method of

collecting diagnostic data from SQL Server

Page 6: Using extended events for troubleshooting sql server

• It’s the FUTURE• SQL Trace is a deprecated feature in SQL Server 2012

• This makes understanding XE crucial to supporting SQL Server in the future

• Less overhead• Lightweight to minimize impact

• Provides minimum schema of data that is specific to the event being fired

• Events are filtered early in the firing lifecycle based on the predicates

• Flexibility and Power• Allows complex configurations for event collection that simplify problem

identification.

• Many events in more recent releases

Why Extended Events?

Page 7: Using extended events for troubleshooting sql server

• Events Mapping Query

• Column to Action Mapping Query

Switch from SQL Trace to XEvents

select xe.xe_event_name,st.namefrom sys.trace_xe_event_map as xeinner join sys.trace_events as ston xe.trace_event_id = st.trace_event_id;

select xe.xe_action_name, tc.namefrom sys.trace_xe_action_map as xeinner join sys.trace_columns as tcon xe.trace_column_id = tc.trace_column_id;

Page 8: Using extended events for troubleshooting sql server

• Sessions• Are a functional boundary for configuration of events

• Events• Correspond to well-know points of code

• Predicates• Boolean expressions that define the conditions required for an event to actually

fire

• Actions• Actions only execute after predicate evaluation determines the event will fire

• Targets• Targets are event consumers

Extended Events Architecture

Page 9: Using extended events for troubleshooting sql server

Event Life Cycle

Event point

encountered in code

Is Event

Enabled in a

sessionCode Continues

Buffer Data for

Asynchronus Targets

Send to Synchronous

Targets Immediately

Execute Actions and

Collect data

(if applicable)

Are there

configurable

columns

Collect

non-configurable

column data

Passes Filter

Criteria

(Predicate)

Collect Configurable

Column data

No

No

Yes

Yes

Yes

Page 10: Using extended events for troubleshooting sql server

• Event counter• Counts all specified events that occur during an Extended Events session.

• Use to obtain information about workload characteristics without adding the

overhead of full event collection.

• This is a synchronous target.

• Event file• Use to write event session output from complete memory buffers to disk.

• This is an asynchronous target.

Targets - 1

Page 11: Using extended events for troubleshooting sql server

• Event pairing• Many kinds of events occur in pairs, such as lock acquires and lock releases.

• Use to determine when a specified paired event does not occur in a

matched set.

• This is an asynchronous target.

• Event Tracing for Windows (ETW)• Use to correlate SQL Server events with Windows operating system or

application event data.

• This is a synchronous target.

Targets - 2

Page 12: Using extended events for troubleshooting sql server

• Histogram• Use to count the number of times that a specified event occurs, based on a

specified event column or action.

• This is an asynchronous target.

• Ring buffer• Use to hold the event data in memory on a first-in first-out (FIFO) basis, or

on a per-event FIFO basis.

• This is an asynchronous target.

Targets - 3

Page 13: Using extended events for troubleshooting sql server

DEMO

CHAPTER

Use case scenarios of Extended Events

Page 14: Using extended events for troubleshooting sql server

SQL Server 2016

Page 15: Using extended events for troubleshooting sql server

• Live Query Stats (LQS)

• Query Store

SQL Server 2016

Page 16: Using extended events for troubleshooting sql server
Page 17: Using extended events for troubleshooting sql server

Thank you

Page 18: Using extended events for troubleshooting sql server

SELECT

KNOWLEDGE

FROM

SQL SERVER

http://www.sqlschool.gr

Copyright © 2015 SQL School Greece