我们正在构建一个最初将是1 TB的数据仓库,并且每月将增长20gig。
对于某些表,我们每天进行ETL流程,而另一些表则每周/每月进行。
当有数据导入到表中时,是否有必要删除并重新创建索引?
是否有必要删除和重新创建索引,或者它们会自动更新?
统计信息设置为自动更新。
非常感谢您的帮助和指导。
我得到了这个天才脚本:
SELECT 'ALTER INDEX [' + ix.name + '] ON [' + s.name + '].[' + t.name + '] ' +
CASE WHEN ps.avg_fragmentation_in_percent > 40 THEN 'REBUILD' ELSE 'REORGANIZE' END +
CASE WHEN pc.partition_count > 1 THEN ' PARTITION = ' + cast(ps.partition_number as nvarchar(max)) ELSE '' END
FROM sys.indexes AS ix INNER JOIN sys.tables t
ON t.object_id = ix.object_id
INNER JOIN sys.schemas s
ON t.schema_id = s.schema_id
INNER JOIN (SELECT object_id, index_id, avg_fragmentation_in_percent, partition_number
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL)) ps
ON t.object_id = ps.object_id AND ix.index_id = ps.index_id
INNER JOIN (SELECT object_id, index_id, COUNT(DISTINCT partition_number) AS partition_count
FROM sys.partitions
GROUP BY object_id, index_id) pc
ON t.object_id = pc.object_id AND ix.index_id = pc.index_id
WHERE ps.avg_fragmentation_in_percent > 10 AND
ix.name IS NOT NULL
从这里:
http://weblogs.asp.net/okloeten/archive/2009/01/05/6819737.aspx
您是否建议我每天运行此脚本,并根据发现结果运行生成的代码?