Created
October 4, 2018 21:53
-
-
Save sqldeployhelmet/d1c7bc55185050f851a4fed76de2592e to your computer and use it in GitHub Desktop.
This file contains 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
SELECT o.name AS [Table_Name] | |
, x.name AS [Index_Name] | |
, i.partition_number AS [Partition] | |
, i.index_id AS [Index_ID] | |
, x.type_desc AS [Index_Type] | |
, i.leaf_update_count * 100.0/ ( i.range_scan_count + i.leaf_insert_count + i.leaf_delete_count | |
+ i.leaf_update_count + i.leaf_page_merge_count + i.singleton_lookup_count) AS [Percent_Update] | |
, i.range_scan_count * 100.0/ ( i.range_scan_count + i.leaf_insert_count + i.leaf_delete_count | |
+ i.leaf_update_count + i.leaf_page_merge_count + i.singleton_lookup_count) AS [Percent_Scan] | |
FROM sys.dm_db_index_operational_stats(DB_ID(), NULL, NULL, NULL) i | |
JOIN sys.objects o ON o.object_id = i.object_id | |
JOIN sys.indexes x ON x.object_id = i.object_id | |
AND x.index_id = i.index_id | |
WHERE ( i.range_scan_count + i.leaf_insert_count + i.leaf_delete_count + leaf_update_count | |
+ i.leaf_page_merge_count + i.singleton_lookup_count) != 0 | |
AND OBJECTPROPERTY(i.object_id, 'IsUserTable') = 1 | |
AND o.name = '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment