Preemptive_xe_dispatcher

preemptive_xe_dispatcher

The preemptive_xe_dispatcher is a feature in SQL Server that allows you to collect extended events data in a synchronous manner. Extended events are lightweight performance monitoring and troubleshooting infrastructure built into SQL Server. They provide valuable information about the internal operations of the database engine.

By default, extended events are collected using a post-event delivery mode, which means events are collected asynchronously in the background. The preemptive_xe_dispatcher feature introduces a new delivery mode called target_data_stream, which allows you to collect events synchronously.

The main advantage of using preemptive_xe_dispatcher is that it ensures all events are collected in the correct order they were fired. This can be particularly useful in cases where event order is critical for analysis and troubleshooting purposes.

To use the preemptive_xe_dispatcher, you need to create an Extended Events session with the target_data_stream delivery mode. Here’s an example:


CREATE EVENT SESSION MySession ON SERVER
ADD EVENT sqlserver.sql_statement_completed (
  ACTION (sqlserver.database_id, sqlserver.sql_text)
)
ADD TARGET package0.event_stream (
  SET delivery_mode = synchronous
);

ALTER EVENT SESSION MySession
STATE = START;
  

In this example, we create an Extended Events session called MySession and add the sql_statement_completed event. We also specify the target_data_stream as the target with the delivery mode set to synchronous. Finally, we start the session.

With the preemptive_xe_dispatcher feature and the target_data_stream delivery mode, you can ensure accurate collection and ordering of events in your SQL Server environment.

Leave a comment