如何找到具有 statistics_norecompute = ON 的索引 [英] How do I find indexes that have statistics_norecompute = ON

查看:33
本文介绍了如何找到具有 statistics_norecompute = ON 的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个 SQL Server 2005 查询,该查询将列出所有索引及其各自的 STATISTICS_NORECOMPUTE 值.我在 sysindexes 中没有看到与该值对应的任何明显值.

I'm looking for a SQL Server 2005 query that will list all the indexes and with their respective STATISTICS_NORECOMPUTE value. I didn't see any obvious value in sysindexes that corresponds to that value.

推荐答案

sys.stats

The column is no_recompute in sys.stats which says

每个索引都会有一个对应的具有相同名称和 ID 的统计行(sys.indexes.object_id = sys.stats.object_id AND sys.indexes.index_id = sys.stats.stats_id),但并不是每个统计行都有一个对应的索引.

Every index will have a corresponding statistics row with the same name and ID (sys.indexes.object_id = sys.stats.object_id AND sys.indexes.index_id = sys.stats.stats_id), but not every statistics row has a corresponding index.

因此 sys.indexes 和 sys.stats 之间的 JOIN 将为您匹配索引

So a JOIN between sys.indexes and sys.stats will match the index for you

原因:

  • 统计数据可以用于列或索引
  • 一个索引只有一个统计信息.
  • STATISTICS_NORECOMPUTE 适用于该索引的统计信息,而不是索引本身

这篇关于如何找到具有 statistics_norecompute = ON 的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆