When was the index statistics updated?

Is there a quick and easy way to list when each index in the database last updated statistics? The preferred answer would be a request. In addition, is it possible to determine the "quality" of statistics: FULLSCAN, SAMPLE n, etc.

EDIT
this worked for what I needed, a small mod for @OrbMan is a great answer ...

SELECT
    STATS_DATE(i.object_id, i.index_id) AS LastStatisticsDate
        ,o.Name AS TableName
        ,i.name AS IndexName
    FROM sys.objects            o
        INNER JOIN sys.indexes  i ON o.object_id = i.object_id
    WHERE o.is_ms_shipped=0
    ORDER BY 1 DESC
+3
source share
1 answer

You can do: STATS_DATE (table_id, index_id)

So:

USE AdventureWorks;
GO
SELECT 'Index Name' = i.name, 'Statistics Date' = STATS_DATE(i.object_id, i.index_id)
FROM sys.objects o
JOIN sys.indexes i ON o.name = 'Address' AND o.object_id = i.object_id;
GO

where Address is the name of the table whose indexes you would like to examine.

+7
source

Source: https://habr.com/ru/post/1710082/


All Articles