Question : USING dm_db_index_physical_stats<wbr /> effectively

Hi,

I've spent the last few days playing arround with dm_db_index_physical_stats to try and dynamically REBUILD/REORGANIZE indexes.

Using dm_db_index_physical_stats I get a list of indexes that have a avg_page_space_used_in_percent value > 60.

So as the acticles say I should run a rebuild on these indicies. So I simply run...

ALTER INDEX ALL ON Practice.ISOL1471 REBUILD WITH (FILLFACTOR=90, ONLINE=ON);

Which complete with success.

I run dm_db_index_physical_stats for a second time. This is where I'm confused as I get the same level of defrag. Which would suggest that no defragmentation has taken place.

This is driving me up the wall. Any suggestions ???

Thanks in advance
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
SELECT  OBJECT_NAME(s.object_id) AS Table_Name, avg_page_space_used_in_percent, avg_fragmentation_in_percent  
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, 'DETAILED') s
WHERE OBJECT_NAME(s.object_id) = 'ISOL1471' AND
	(
	(avg_page_space_used_in_percent > 60) OR 
	(avg_fragmentation_in_percent < 15)
	)
 
ALTER INDEX ALL ON Practice.ISOL1471 REBUILD WITH (FILLFACTOR=90, ONLINE=ON);
 
SELECT  OBJECT_NAME(s.object_id) AS Table_Name, avg_page_space_used_in_percent, avg_fragmentation_in_percent  
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, 'DETAILED') s
WHERE OBJECT_NAME(s.object_id) = 'ISOL1471' AND
	(
	(avg_page_space_used_in_percent > 60) OR 
	(avg_fragmentation_in_percent < 15)
	)

Answer : USING dm_db_index_physical_stats<wbr /> effectively

>>Do I need STATISTICS NORECOMPUTE ???
No

>>What is a good threshold for the row count ???
Its hard to gauge really....it depends on how large the rows are and how many of them there are.  I would say anything more than 25,000 or so might be a good candidate to reindex...but that is just guesstimate.  
Random Solutions  
 
programming4us programming4us