Maybe you’re a user in a reporting database running a long query in the read committed isolation level, merrily blocking a process which needs to load data.
Maybe you’re an application misbehaving in a transactional front end database, blocking other applications.
Or possibly you’re a middle tier application who is behaving well and trying to do a small update, but the table you’re updating holds a legacy trigger designed when it was a much smaller table, and that trigger is doing data validation with long running locks.
With there being a lot of users, a lot of applications, and in general a lot of blocking, it can be useful to get a bird’s eye view.
I manage a system where we frequently used to see lots of blocking related to triggers. We’d see one spid block another, and then that spid block a few more, and so on. We would also occasionally see a middle tier application open a connection and start doing work, then stop activity but leave a transaction open. In that case it could hold locks until the connection terminated, even though the spid was sleeping.
So it was extremely useful to be able to see quickly who the spids were at the root of the blocking trees. There would often be a very large number of connections open sp_who2 wasn’t the easiest method.
I also like to collect the execution plans for blockers, which makes it much easier to track down the cause.
Hence, this script…
Continue Reading →
Comments