Home >Database >Mysql Tutorial > 使用默认system_health分析死锁(Deadlock)

使用默认system_health分析死锁(Deadlock)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:52:001137browse

在2008之前我们分析死锁需要用profilertrace或者traceflag1222,1204.在2008中引入了一个新功能:ExtendedEvents(扩展事件),可以监控Deadlock事件,并且性能更好

 

SELECT    xed.value('@timestamp', 'datetime') as Creation_Date,          xed.query('.') AS Extend_Event  FROM    (    SELECT    CAST([target_data] AS XML) AS Target_Data              FROM    sys.dm_xe_session_targetsAS xt                      INNERJOIN sys.dm_xe_sessions AS xs                      ONxs.address = xt.event_session_address              WHERE    xs.name = N'system_health'                      ANDxt.target_name =N'ring_buffer')  AS XML_Data  CROSS APPLY Target_Data.nodes('RingBufferTarget/event[@name="xml_deadlock_report"]') AS XEventData(xed)  ORDER BY Creation_Date DESC

 

wKiom1PjG1SCRa7pAAHP0eEHWjk097.jpg

 

wKiom1PjG1XjhYX-AAPmb8Sm6Ns936.jpg

本文出自 “关注SQL Server技术” 博客,请务必保留此出处

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn