Skip to content
 

Find Missing Table and Index Statistics

Missing statistics can severely impact execution plan generation. If the statistics are out of date SQL Server will behave in bizarre ways. When this becomes the problem, it is very hard to troubleshoot because there are no physical indicators. Instead, everything just runs poorly. In order to find missing our out of date statistics, run the following:

SELECT
	Last_Updated	= STATS_DATE(si.id, si.indid)
	,TableName		= object_name(si.id)
	,Name			= RTRIM(si.name)
	,Size			= DATALENGTH (si.statblob)
FROM
	sysindexes si WITH (nolock)
WHERE OBJECTPROPERTY(si.id, N'IsUserTable') = 1
--AND INDEXPROPERTY (si.id , si.name , 'IsAutoStatistics' ) = 0
order by last_updated, tablename

Related Posts:

Ask a question or post a comment