sql-server – 增量更新后统计信息消失
发布时间:2020-12-26 01:10:25 所属栏目:站长百科 来源:网络整理
导读:副标题#e# 我们有一个使用增量统计信息的大型分区SQL Server数据库.所有索引都按分区对齐.当我们尝试通过分区在线重建分区时,所有统计信息在重建索引后都会消失. 下面是使用AdventureWorks2014数据库在SQL Server 2014中复制问题的脚本. --Example against
|
因此,长话短说:增量统计可以是一个有用的工具,具有适当的思考和初始设置工作.但是,您必须知道您尝试解决的问题,然后您需要适当地解决它.如果您的基数估计值不佳,您可能会获得更好的战略抽样率和一些投资干预计划.但是,由于使用的直方图是单个合并的统计信息页而不是分区级信息,因此您只获得了一小部分好处.如果您在维护窗口感到痛苦,那么增量统计可能对您有所帮助,但可能需要您设置高接触维护干预流程.无论如何,请记住requirements for incremental statistics: >使用与基表不分区对齐的索引创建的统计信息. 希望这可以帮助 select
sysdatetime(),leading_column = index_col(quotename(sh.name)+'.'+quotename(t.name),parition_number = isnull(sp.partition_number,modification_counter = coalesce(sp.modification_counter,n1.modification_counter)
from sys.stats s
join sys.tables t
on s.object_id = t.object_id
join sys.schemas sh
on t.schema_id = sh.schema_id
left join sys.indexes i
on s.object_id = i.object_id
and s.name = i.name
cross apply sys.dm_db_stats_properties_internal(s.object_id,s.stats_id) sp
outer apply sys.dm_db_stats_properties_internal(s.object_id,s.stats_id) n1
where n1.node_id = 1
and (
(is_incremental = 0)
or
(is_incremental = 1 and sp.partition_number is not null)
)
and t.name = 'Posts'
and s.name like 'st_posts%'
order by s.stats_id,isnull(sp.partition_number,1) (编辑:网站开发网_安阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐

