I'm querying Xevents XML that I have collected, and there is something that I dont quite understand, my definition is for statements taking more than 100 milliseconds and also get the wait type as well. Now that works fine, however when I collect the entire information and then want to find out how long was spent on each wait type. I am effectively running a select statement similar to the below
select Wait_Type, sum(Total_Duration) Total_Duration_MS from #Aggs group by Wait_Type
However I'm finding that the timing doesnt make sense, for example I get an result looking like this.
CXPACKET 65413
LATCH_EX 3457
PAGEIOLATCH_EX 951
PAGEIOLATCH_SH 87689
However I know the calculation isnt right as the section that I'm interested in only took 77 seconds, but looking at the total of the duration for the spid, its already more than 77 seconds, i was expecting it to be closer to 77 seconds or slightly under.
If anyone can explain how they can use XEvents to filter out a query and its wait type whilst the query executed, that would be helpful as I think there is something wrong with the above.