在MS SQL (mssql)中查找阻塞/锁定查询

时间:2022-07-23 23:50:48

Using sys.dm_os_wait_stats I have identified what I believe is a locking problem

使用系统。dm_os_wait_stats我已经确定了我认为的锁定问题

  wait type    waittime  pct     running ptc
  LCK_M_RS_S   2238.54   22.14   22.14
  LCK_M_S      1980.59   19.59   41.73

Is there a way I can find the top blocking/locking queries? I've tried querying sys.dm_db_index_operational_stats without much luck.

有办法找到顶部的阻塞/锁定查询吗?我试着查询系统。dm_db_index_operational_stats没有多少运气。

2 个解决方案

#1


19  

You may find this query useful:

您可能会发现这个查询很有用:

SELECT * 
FROM sys.dm_exec_requests
WHERE DB_NAME(database_id) = 'YourDBName' 
AND blocking_session_id <> 0

#2


3  

Use the script: sp_blocker_pss08 or SQL Trace/Profiler and the Blocked Process Report event class.

使用脚本:sp_blocker_pss08或SQL Trace/Profiler和阻塞的进程报告事件类。

#1


19  

You may find this query useful:

您可能会发现这个查询很有用:

SELECT * 
FROM sys.dm_exec_requests
WHERE DB_NAME(database_id) = 'YourDBName' 
AND blocking_session_id <> 0

#2


3  

Use the script: sp_blocker_pss08 or SQL Trace/Profiler and the Blocked Process Report event class.

使用脚本:sp_blocker_pss08或SQL Trace/Profiler和阻塞的进程报告事件类。