SQL Mysteries: Causality tracking vs Event Sequence for XEvent Sessions


Moved from: bobsql.com

 

You need to make sure to order the events by event_sequence when doing analytics on the XEvent data. It has been proposed to me that you can use the causality tracking sequence as a sort target, which may work as long as you understand how the activity ids are associated with the parent and the sequence is produced.

 

https://techcommunity.microsoft.com/t5/SQL-Server-Support/How-It-Works-XEvent-Output-and-Visualization/ba-p/318369
https://bobsql.com/viewing-and-sorting-xevents-efficiently-code-samples-xeprofiler/

Summary

Values are generated when the event sequence is submitted to the target
Values are always incremented
The event_sequence is unique to the session
The activity id is unique to the task with xfer reference