SQL死锁情况汇总排查

Posted soleds

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL死锁情况汇总排查相关的知识,希望对你有一定的参考价值。

select dbname,entity_name,count(1) as locks from 
(SELECT request_session_id AS spid,  
       DB_NAME(resource_database_id) AS dbname,  
       CASE WHEN resource_type=‘object‘   
                 THEN OBJECT_NAME(resource_associated_entity_id)   
            WHEN resource_associated_entity_id=0 THEN ‘n/a‘  
            ELSE OBJECT_NAME(p.object_id) END AS entity_name,  
       index_id,  
       resource_type AS RESOURCE,  
       resource_description AS DESCRIPTION,  
       request_mode AS mode,  
       request_status AS STATUS   
FROM sys.dm_tran_locks t LEFT JOIN sys.partitions p ON p.partition_id=t.resource_associated_entity_id  
WHERE resource_database_id=DB_ID()) as a group by a.dbname,a.entity_name

  

以上是关于SQL死锁情况汇总排查的主要内容,如果未能解决你的问题,请参考以下文章

JAVA死锁排查-性能测试问题排查思路

Java死锁排查

sql server 死锁排查

Sql server 死锁排查

SQL Server死锁排查

sql server 性能调优之 死锁排查