开发者

Obtaining the name of the index locked for a Lock:Acquired trace event

I'm capturing Lock:Acquired trace events ui开发者_如何学编程ng SQL Server Profiler and I would like to be able to identify the name of the index that the lock applies to for KEY type locks.

I can do this for OBJECT lock types (by executing the following query using the value from the ObjectID column in the trace):

SELECT OBJECT_ID( /* my object id */ )

However for KEY lock types the ObjectID column is empty, and the ObjectID2 column contains a bigint value, which is too large to work using the above query.

How can I find what index a KEY lock applies to from my trace?


Have a look at this answer from a very intelligent SQL Server MVP

http://www.eggheadcafe.com/software/aspnet/33177368/what-is-the-objectid2-column-for-locks-acquired-referring-to.aspx

If you captured your lock trace, and while the transaction is open, in Query Windows enter this

select * from sys.dm_tran_locks
exec sp_lock

You will see various information that correlate mostly to the TextData column in the trace. That appears to be a physical page/location within that is being locked - no locks are placed on indexes per-se, locks are mostly for KEY (record) or PAGE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜