Tuesday, February 14, 2012

Last update stats time

Ever wondered when was the last time the statistics got updated. If yes, then use the following query against the database and find that last time the stats got updated.


select a.id as 'ObjectID', isnull(a.name,'Heap') as 'IndexName', b.name as 'TableName',
stats_date (id,indid) as stats_last_updated_time
from sys.sysindexes as a
inner join sys.objects as b
on a.id = b.object_id
where b.type = 'U' and b.name !=  a.name order by stats_last_updated_time desc

If it's been a while since the statistics got updated then please update the statistics.

No comments:

Post a Comment