How do I tell the fragmentation levels of my tables?

×

Index Fragmenation is an important metric to monitor. The following query will display the relative health of your indexes.


select * from sys.dm_db_index_physical_stats(db_id('My Database'),null,null,null,'SAMPLED')
where page_count>=8
and avg_fragmentation_in_percent>=10
order by avg_fragmentation_in_percent desc