I have a large database running on SQL Server 2005. I query the DMV sys.dm_db_index_physical_stats to get index fragmentation information.
I was shocked to see avg_fragment_size_in_percent reporting a large amount of indexes with very bad fragmentation levels (99% for a lot of them). These are on tables with non-trivial page counts (500+ pages on the smallest ones).
I proceded to run the following on the worst offenders:
ALTER INDEX ALL ON myTable REBUILD WITH(ONLINE = ON)
I then re-queried sys.dm_db_index_physical_stats, however it reports exactly the same fragmentation levels before and after the index REBUILD.
Is this information cached, or am I doing something wrong?