0

I've inherited of a couple of databases which indexes have never been maintained (rebuilt, reorganized).

I'm using Ola Hallengren's Index maintenance script, I've used the following script to record the difference between the pre-maintenance and post-maintenance values.

Script :

SELECT  OBJECT_NAME(IPS.object_id) AS [TableName] ,
    SI.name AS [IndexName] ,
    IPS.Index_type_desc ,
    IPS.avg_fragmentation_in_percent ,
    IPS.avg_fragment_size_in_pages ,
    IPS.avg_page_space_used_in_percent ,
    IPS.record_count ,
    IPS.ghost_record_count ,
    IPS.fragment_count 
   -- ,IPS.avg_fragment_size_in_pages
FROM    
    sys.dm_db_index_physical_stats(DB_ID(N'test_db'), NULL, NULL, NULL, 'DETAILED') IPS
JOIN 
    sys.tables ST WITH (NOLOCK) ON IPS.object_id = ST.object_id
JOIN 
    sys.indexes SI WITH (NOLOCK) ON IPS.object_id = SI.object_id
                                 AND IPS.index_id = SI.index_id
WHERE   
    ST.is_ms_shipped = 0
ORDER BY 
    3 Desc, 4 Desc

However, I didn't notice any changes on the various indexes having an avg_fragmentation_in_percent above 30%.

Are index maintenance tasks supported on SQL Server 2008R2 Web Editions?

2
  • 2
    I believe you're bumping up against this.
    – swasheck
    Commented Oct 18, 2013 at 18:17
  • 1
    Thanks it really help understanding the issue, another ressource -
    – Raymond
    Commented Oct 18, 2013 at 19:58

1 Answer 1

0

For small tables (typically reduced pages count), fragmentation cannot be avoided due to how sql server handles extents.

More info : http://www.practicalsqldba.com/2012/04/sql-server-measuring-index.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.