Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Rebuiliding indexes and impact on average_fragmentation.

$
0
0

I ran this query on our sql 2008 server:


select 
         object_name(object_id) ,index_type_desc, 
         avg_fragmentation_in_percent
from sys.dm_db_index_physical_stats (DB_ID('MyDB'), NULL, NULL, NULL, NULL)
where index_type_desc like '%INDEX%'
order by avg_fragmentation_in_percent desc

and found that table "chairs" clustered index had 62.5% fragmentation. When I ran

alter index all on chairs
rebuild

the index fragmentation went down to only 50% (I expected a number a lot closer to 0%). I ran the rebuild again but this time the fragmentation jumped to about 65%. What am I doing wrong?  (If my results are accurate, there seems to be no reason to rebuild tables indexes at all as the avg fragmentation % can go in any direction.)

TIA,

edm2


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>