Quirks When Working With Extended Events To Track Locks

SQL Server

Worse Than Mobile Browsing

I have a love/hate relationship with Extended Events. Yes, they’re powerful. Yes, you can track interesting things.

But they’re just not intuitive, like, 10 years on.

Part of the problem is that the narrative from Microsoft has been that it’s a full replacement for Profiler and Traces.

How many monitoring tool vendors do you see using Extended Events instead?

Trying To Do Something Simple

Tracking locks should be very easy, right? There’s locks everywhere.

But right away, there’s a problem.

I have a User Thing issue about this open.


The issue is that LAST_MODE should map to RX_X, but it doesn’t.

Leaving aside the juvenile word searches one could explore here, if you were trying to figure out a bad locking problem, what would you think of LAST_MODE?

Probably not much, but the wait that it maps to is usually due to Serializable locking.

Not something you wanna ignore.

Speaking Of Locks…

If you were trying to figure out how to see which objects were locked, what of these would you look at?

object misery

There are five columns that purport to have an object ID in them. None of them ever seem to resolve when you use OBJECT_NAME.

In fact, most of them fail, because they’re populated with bigger ints than OBJECT_NAME can cope with.

If you were to create an XE session to look at locks, and then try to parse things out, you’d have to do something like this:

The associated_object_id maps to the hobt_id column in sys.partitions.

Which is per-database. Context is everything.

I didn’t see a better way to do this when looking at the Global Fields you can collect.

Not exactly intuitive.


When you’re going to use Extended Events, there’s a heck of a lot of shruggery involved.

Which event(s) do I need? What do they actually capture? What really triggers them? What sort of target should I use? If I allow events to be lost, will I miss what I’m looking for?

None of this stuff is obvious, which puts anyone trying to use them to track down or solve a problem for the first time at a real disadvantage. I use them fairly frequently (compared to a lot of people I know), and I still get hung up on stuff.

At the beginning of the article, I said XE is worse than mobile browsing.

That sounds harsh, but hear me out: if you’re on your phone (server), and there’s an article (event) you’re interested in, what’s an easy way for you to lose interest quick?

Clicking on a link, getting a full screen pop up ad, then a request to allow notifications, then a pop up window, one of those scroll past ads, maybe some auto play video for good measure. If you’re really lucky, you’ll get a notification that you won a hot local single.

I’m reminded of all those annoyances every time I go to do something with Extended Events. There’s a lot standing in the way of me acquiring an interesting piece of information. They should have a lot more going for them by now, but even just figuring out microseconds or milliseconds is a pain.

My Friend From Slack, Steve Jones, said something along the lines of: Software should make people’s lives easier.

Right now, Extended Events often introduce a lot of complications just trying to answer relatively simple questions.

Thanks for reading!

Previous Post
Should You Use the New Compatibility Modes and Cardinality Estimator?
Next Post
Should Index Changes Require Change Control?

8 Comments. Leave new

  • Great post Er… B… Erik!

    Kudos to you for Raising Awareness on the many WTFs on Extended Events. I love how lightweight they are and all the stuff you can expose with them, but trying to figure out how to configure the session and then deconfrigulate the XML is worse than trying to get a squat rack at 5:30 on a Friday.

    They’re on my short list of things to get less-awful at, what for the monitoring and performance tuning and all. As the saying goes; “Extended Events are like Crossfit; if you don’t know what you’re doing, just do everything and hope for the best.”

    • Brandon — yeah, that’s another sign that it’s flailing. It’s been around for 10 years, and it’s still on a lot of lists of “things I wanna check out someday”.

      Like the 500mg of Test E I wanna take every time I fail a PR.

  • Thanks for bringing attention to this. I would add that I hate querying XML, so I only look at live data with XE. I have a saved script for XE that looks at what queries are being run and when they complete. Anything else I’d want to look at and I’m up a creek. At the very very least msoft could come up with some good canned choices, e.g. slow queries, wait times, etc.

    • Agreed here. I spend a lot of time working with XML for plan cache queries, and I always dread working with it for XE.

  • Seconded on the units thing – I love the instrumentation in SQL Server but why don’t the column names include the measurement units, is it seconds, milliseconds, microseconds or ticks. megabytes, extents, pages, kilobytes or just bytes.

    • Better yet, let people choose the granularity. When’s the last time bytes or microseconds helped anyone fix a problem?


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.