En utilisant sys.dm_os_wait_stats
J'ai identifié ce que je crois être un problème de verrouillage
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
Existe-t-il un moyen de trouver les principales requêtes de blocage/verrouillage? J'ai essayé d'interroger sys.dm_db_index_operational_stats
sans beaucoup de chance.
Vous pouvez trouver cette requête utile:
SELECT *
FROM sys.dm_exec_requests
WHERE DB_NAME(database_id) = 'YourDBName'
AND blocking_session_id <> 0
Utilisez le script: sp_blocker_pss08 ou SQL Trace/Profiler et la classe d'événements Blocked Process Report.
J'ai trouvé cette requête qui m'a aidé à trouver ma table verrouillée et la requête à l'origine du problème.
SELECT L.request_session_id AS SPID,
DB_NAME(L.resource_database_id) AS DatabaseName,
O.Name AS LockedObjectName,
P.object_id AS LockedObjectId,
L.resource_type AS LockedResource,
L.request_mode AS LockType,
ST.text AS SqlStatementText,
ES.login_name AS LoginName,
ES.Host_name AS HostName,
TST.is_user_transaction as IsUserTransaction,
AT.name as TransactionName,
CN.auth_scheme as AuthenticationMethod
FROM sys.dm_tran_locks L
JOIN sys.partitions P ON P.hobt_id = L.resource_associated_entity_id
JOIN sys.objects O ON O.object_id = P.object_id
JOIN sys.dm_exec_sessions ES ON ES.session_id = L.request_session_id
JOIN sys.dm_tran_session_transactions TST ON ES.session_id = TST.session_id
JOIN sys.dm_tran_active_transactions AT ON TST.transaction_id = AT.transaction_id
JOIN sys.dm_exec_connections CN ON CN.session_id = ES.session_id
CROSS APPLY sys.dm_exec_sql_text(CN.most_recent_sql_handle) AS ST
WHERE resource_database_id = db_id()
ORDER BY L.request_session_id