In today’s article, we will be discussing the importance of seeing when SQL Server Statistics were last updated for the system.
Statistics have a significant performance benefit in database systems.
Queries draw their own path (execution plan) by looking at the statistics collected while they are running, and with the help of these paths, queries run fast.
In some cases, when statistics are not up to date, our queries run slowly, and due to this slowness, accumulations and unnecessary CPU and disk usage increase.
In order to prevent these, we may need to check our statistics.
With the query below, you can see the last time your database-based statistics were updated.
1 2 3 4 5 6 |
SELECT OBJECT_NAME(object_id) AS [ObjectName] ,[name] AS [StatisticName] ,STATS_DATE([object_id], [stats_id]) AS [StatisticUpdateDate] ,datediff(DAY,(STATS_DATE([object_id], [stats_id])),GETDATE()) AS [kacgündürgüncellenmediği] FROM sys.stats where OBJECT_NAME(object_id) not like 'sys%' |
You can update your outdated statistics by using UPDATE STATISTICS.