Sql server 何时重建和何时重新组织索引

Sql server 何时重建和何时重新组织索引,sql-server,sql-server-2008,sql-server-2005,sql-server-2012,Sql Server,Sql Server 2008,Sql Server 2005,Sql Server 2012,我一直试图收集有关重建和重新组织索引的信息。从stackoverflow页面()中,我得到了以下查询: SELECT t.NAME 'Table name', i.NAME 'Index name', ips.index_type_desc, ips.alloc_unit_type_desc, ips.index_depth, ips.index_level, ips.avg_fragmentation_in_percent, i

我一直试图收集有关重建和重新组织索引的信息。从stackoverflow页面()中,我得到了以下查询:

SELECT 
    t.NAME 'Table name',
    i.NAME 'Index name',
    ips.index_type_desc,
    ips.alloc_unit_type_desc,
    ips.index_depth,
    ips.index_level,
    ips.avg_fragmentation_in_percent,
    ips.fragment_count,
    ips.avg_fragment_size_in_pages,
    ips.page_count,
    ips.avg_page_space_used_in_percent,
    ips.record_count,
    ips.ghost_record_count,
    ips.Version_ghost_record_count,
    ips.min_record_size_in_bytes,
    ips.max_record_size_in_bytes,
    ips.avg_record_size_in_bytes,
    ips.forwarded_record_count
FROM 
    sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') ips
INNER JOIN  
    sys.tables t ON ips.OBJECT_ID = t.Object_ID
INNER JOIN  
    sys.indexes i ON ips.index_id = i.index_id AND ips.OBJECT_ID = i.object_id
WHERE
    AVG_FRAGMENTATION_IN_PERCENT > 0.0  
ORDER BY
    AVG_FRAGMENTATION_IN_PERCENT, fragment_count
问题是,当我重建索引时,平均碎片百分比增加而不是减少。有什么建议吗??如果这是正常的行为,那么我在这里遗漏了什么

以前,平均碎片百分比为30,重建后增加到66

问题是,当我重建索引时,平均碎片百分比增加而不是减少。有什么建议吗??如果这是正常的行为,那么我在这里遗漏了什么


如果索引很小,这是正常行为。如果索引有page_cont,请尝试发布表格的填充因子以及表格布局。听起来您需要根据重建结果调整填充因子。@JStead:我已经上传了屏幕截图。。填充因子是0。这是一个非常小的索引,基于您拥有的统计数据。此外,表非常瘦。在每一步重建索引时,将填充因子从95降到70左右,每5块一块。如果你在10-20%的碎片范围内,根据这张桌子有多小,我会说它完成了任务。