SQL Server Performance Tuning - Extended Events

Explore the power of Extended Events for real-time monitoring and troubleshooting of your SQL Server instances.

Introduction to Extended Events

Extended Events (EE) is a powerful tool for real-time monitoring, diagnostics, and troubleshooting of SQL Server. It provides a detailed view into your database activity, allowing you to identify performance bottlenecks and potential issues before they impact your users.

Unlike traditional SQL Server Profiler, Extended Events are lightweight and don't significantly impact database performance. They are designed to collect granular data without adding significant overhead.

Key Features:

Creating an Event Session

The first step in using Extended Events is to create an event session. You can configure the session to capture specific events based on your monitoring needs.

Example: Capturing Login Events


CREATE EVENT SESSION LoginEvents ON SERVER
ADD EVENT Login (
    SQLHOST_APP = ANY_VALUE,
    DATABASE_ID = ANY_VALUE
)
    WITH (MAX_DATA_SIZE = 2048KB, TRACK_NOWAIT);
            

Explanation:

Querying Event Data

Once you've created an event session, you can query the collected event data using the `EVENTDATA` function.


SELECT *
FROM EVENTDATA()
WHERE start_time < GETDATE() - 1;
            

Explanation: