Wednesday, 20 December 2017

Index Fragmentation on MS SQL

Run the following SQL query to see the fragmentation of table indexes. In this example I am checking my SolarWindsOrion database

SELECT OBJECT_NAME(OBJECT_ID), index_id,index_type_desc,index_level,
avg_fragmentation_in_percent,avg_page_space_used_in_percent,page_count
FROM sys.dm_db_index_physical_stats
(DB_ID(N'SolarWindsOrion'), NULL, NULL, NULL , 'SAMPLED')
ORDER BY avg_fragmentation_in_percent DESC

No comments:

Post a Comment