I would agree with you. But when I execute the script from page 40 of the SQL Best Practice Guide from EV11 "to identify all tables and indexes where the external fragmentation exceeds 5% and the table consists of at least 1,000 pages" it doesn't find anything.
SELECT OBJECT_NAME(i.object_id) AS TableName,
i.name AS TableIndexName, phystat.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'LIMITED') phystat
JOIN sys.indexes i ON i.object_id = phystat.object_id AND i.index_id = phystat.index_id
WHERE phystat.avg_fragmentation_in_percent > 5 AND phystat.page_count > 1000
The query from https://support.symantec.com/en_US/article.TECH224136.htmlon the other hand does find something. And now it's going to be odd: If I execute both queries I can get two different results on the same DB for the same table for the same tableindex...
Procedure |
Index |
avg_fragmentation_in_percent |
query from SQL BP for EV11 |
PK_JournalArchive |
57,55 |
query from TECH224136 |
PK_JournalArchive |
99,27 |
So how should I handle this inaccuracy?