Hi All,
I observed there are several scripts which can be ran against a database for finding the index fragmentation.
But, none of them returns me the results in quick time. I am after a script which can return results in less than 5 minutes.
For example:
SELECT o.name,
i.name,
ips.index_level,
ips.index_type_desc,
ips.page_count,
ips.record_count,
ips.avg_fragmentation_in_percent,
ips.avg_fragment_size_in_pages,
ips.avg_page_space_used_in_percent
FROM sys.objects o INNERJOIN sys.indexes i
ON(o.object_id= i.object_id)INNERJOIN sys.dm_db_index_physical_stats(db_id(),DEFAULT,DEFAULT,DEFAULT,'DETAILED') ips
ON(
i.object_id = ips.object_idAND
i.index_id = ips.index_id
)
WHERE o.is_ms_shipped =0AND
ips.page_count >=1000AND
ips.avg_fragmentation_in_percent >=60
ORDERBY
o.name ASC,
i.index_id ASC,
ips.index_level ASC;
Any help?
Regards,
kccrga