我想检查哪些索引统计信息在页数为500 MB或更多的表上没有更新。 我有这个脚本:
SELECT OBJECT_NAME(object_id) AS [ObjectName]
,[name] AS [StatisticName]
,STATS_DATE([object_id], [stats_id]) AS [StatisticUpdateDate]
FROM sys.stats
order by StatisticUpdateDate desc
它没有给我所有我想要的信息。有人能够修改我的脚本或告诉我如何到达我想要的位置吗?
提前致谢。
答案 0 :(得分:0)
这是一个500页的解决方案,即使我认为500Mb更合理:
with cte as
(
select p.object_id,
object_name(p.object_id) as obj,
sum(total_pages) as tot_pages
from sys.partitions p join sys.allocation_units au
on au.container_id = p.hobt_id
group by p.object_id
)
SELECT c.* ,
OBJECT_NAME(st.object_id) AS [ObjectName]
,[name] AS [StatisticName]
,STATS_DATE(st.[object_id],
[stats_id]) AS [StatisticUpdateDate]
FROM sys.stats st join cte c
on st.object_id = c.object_id
where tot_pages >= 500;