Created
October 31, 2017 17:18
-
-
Save ronascentes/1080c103f73bfbe7cb6d51d5be14f126 to your computer and use it in GitHub Desktop.
Identify the top 3 objects associated with waits on page locks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://blogs.msdn.microsoft.com/sql_pfe_blog/2009/06/11/three-usage-scenarios-for-sys-dm_db_index_operational_stats | |
SELECT TOP 3 | |
OBJECT_NAME(o.object_id, o.database_id) object_nm, | |
o.index_id, | |
partition_number, | |
page_lock_wait_count, | |
page_lock_wait_in_ms, | |
case when mid.database_id is null then 'N' else 'Y' end as missing_index_identified | |
FROM sys.dm_db_index_operational_stats (db_id(), NULL, NULL, NULL) o | |
LEFT OUTER JOIN (SELECT DISTINCT database_id, object_id | |
FROM sys.dm_db_missing_index_details) as mid | |
ON mid.database_id = o.database_id and mid.object_id = o.object_id | |
ORDER BY page_lock_wait_count DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment