Using SQL Extended Events for Advanced Monitoring and Tuning

Using SQL Extended Events for Advanced Monitoring and Tuning


SQL Extended Events (XEvents) are an efficient, low-impact event handling system for monitoring and diagnosing SQL Server performance and health. This blog post will guide you through enabling and tuning SQL Extended Events, offering deep insights into your database system.

Understanding SQL Extended Events

SQL Extended Events are a part of SQL Server’s event-driven architecture, capable of collecting a wide array of performance and error metrics. They are designed to replace older tools like SQL Profiler and Server-side Trace with more efficient and granular data collection capabilities.

In my mind, they are a complimentary service, not a replacement, but I will leave it for you to decide whether they are a replacement.

Enabling SQL Extended Events

  1. Access Management Studio: Start by opening SQL Server Management Studio (SSMS) and connecting to your database server.
  2. Navigate to Extended Events: In the Object Explorer, expand the ‘Management’ folder and then ‘Extended Events’.
  3. Create a New Session: Right-click ‘Sessions’ and select ‘New Session Wizard’ to start creating an event session. This wizard guides you through the process step-by-step.

Configuring an Extended Event Session

  1. Session Properties: Give your session a meaningful name and decide whether to start the session at server startup. Optionally, specify a template.
  2. Choose Events: Select the events you want to monitor. SQL Server provides a wide range of events, such as sql_statement_completed, deadlock_graph, and error_reported.
  3. Set Filters: To narrow down the data collected, apply filters. For example, filter by database name, SQL text, or duration.
  4. Define Actions: Actions are additional tasks performed each time an event occurs, like capturing the SQL call stack.

Storing Event Data

  • Choose a Target: XEvents can be configured to send output to various targets like event file, ring buffer, or histogram. For long-term analysis, the event file target is commonly used.
  • Configure Storage Options: Specify the file path, maximum file size, and rollover options if you’re using the event file target.

Starting and Using the Session

  • Start the Session: After configuring, start the session either through SSMS or using T-SQL commands.
  • Live Data Monitoring: For immediate analysis, watch live data streaming in SSMS under the ‘Watch Live Data’ option.
  • Analyze Stored Data: For event file targets, use the ‘Extended Events’ viewer in SSMS or query the file using T-SQL.

Tuning Extended Events Sessions

  • Refine Event Selection: Periodically review the events you are collecting. Adjust the selection to ensure you’re capturing relevant data without unnecessary overhead.
  • Optimize Filters: Fine-tune filters to reduce noise in the data, focusing on the most critical information.
  • Performance Impact Analysis: Regularly assess the impact of your XEvents sessions on server performance, adjusting as necessary to minimize overhead.

Best Practices and Considerations

  • Start Small: Begin with a limited number of events and targets, then expand as you become more familiar with the tool.
  • Use Templates: Leverage session templates provided by SQL Server as a starting point.
  • Regular Review: Continuously review and adjust your XEvents sessions to align with your monitoring needs and server changes.


SQL Extended Events offer a powerful and flexible framework for monitoring SQL Server. By carefully enabling, configuring, and tuning your XEvents sessions, you can gain valuable insights into your database’s performance and health with minimal performance overhead.

As SQL Server evolves, so do the capabilities of XEvents, making them an essential tool for any database professional.


Hi, my name is Stephen Finchett. I have been a software engineer for over 30 years and worked on complex, business critical, multi-user systems for all of my career. For the last 15 years, I have been concentrating on web based solutions using the Microsoft Stack including ASP.Net, C#, TypeScript, SQL Server and running everything at scale within Kubernetes.