Created
December 16, 2021 06:17
-
-
Save mephistoc/bdc5e3dab8f3239b52a31fb5d569be41 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 OBJECT_NAME(dt.object_id) as [TableName] , --資料表名稱 | |
si.name as [IndexName] , --索引名稱 | |
dt.avg_fragmentation_in_percent, --邏輯片段的百分比 (索引中失序的頁面)。 | |
dt.avg_page_space_used_in_percent | |
FROM | |
(SELECT object_id , | |
index_id , | |
avg_fragmentation_in_percent, | |
avg_page_space_used_in_percent | |
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, 'DETAILED') | |
WHERE index_id <> 0 | |
) AS dt --does not return information about heaps | |
INNER JOIN sys.indexes si | |
ON si.object_id = dt.object_id | |
AND si.index_id = dt.index_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment