Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Statistics


Statistics

Author
Message
Vinodh247
Vinodh247
SSC Veteran
SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)

Group: General Forum Members
Points: 250 Visits: 758
Hi All,

Good Mrng ! Can anyone tell me what is the common used dmv or sp in query analyzer to find out when was the last statistics updated.

____________________________________________________________________
Going in one more round when you don't think you can - that's what makes all the difference in your life --Rocky Balboa

Believe you can and you're halfway there. --Theodore Roosevelt
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47143 Visits: 44346
STATS_DATE()
It's a function, use it in conjunction with sys.indexes or sys.statistics.

Or, if you just want the details for one stats set, DBCC SHOW_STATISTICS will also show last update.

Bear in mind that stats that haven't been updated for a while are not necessarily a problem. It's only a problem if there have been lots of data changes in the interim.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Vinodh247
Vinodh247
SSC Veteran
SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)

Group: General Forum Members
Points: 250 Visits: 758
Thanks for the reply Gail.

____________________________________________________________________
Going in one more round when you don't think you can - that's what makes all the difference in your life --Rocky Balboa

Believe you can and you're halfway there. --Theodore Roosevelt
Chuck Hottle
Chuck Hottle
SSC Veteran
SSC Veteran (210 reputation)SSC Veteran (210 reputation)SSC Veteran (210 reputation)SSC Veteran (210 reputation)SSC Veteran (210 reputation)SSC Veteran (210 reputation)SSC Veteran (210 reputation)SSC Veteran (210 reputation)

Group: General Forum Members
Points: 210 Visits: 1204
This query has worked for me in determining statistics that may nee to be updated.

USE YourDB;

SELECT   sch.name + '.' + obj.name AS TableName,
   ind.name AS IndexName,       
   STATS_DATE(ind.object_id, ind.index_id) AS LastStatsUpdate,
   last_user_update, P.row_count,
   DATEDIFF(MI,last_user_update, STATS_DATE(ind.object_id, ind.index_id)) AS TimeDiffMinutes
FROM sys.indexes ind
INNER JOIN sys.objects obj
ON obj.object_id = ind.object_id
INNER JOIN sys.schemas sch
ON sch.schema_id = obj.schema_id
INNER JOIN sys.dm_db_index_usage_stats dmv1
ON dmv1.object_id = ind.object_id
AND dmv1.index_id = ind.index_id
INNER JOIN sys.dm_db_partition_stats P
ON P.object_id = ind.object_id
AND P.index_id = ind.index_id
WHERE ind.name IS NOT NULL
AND STATS_DATE(ind.object_id, ind.index_id) IS NOT NULL
AND dmv1.user_updates > 0
AND dmv1.database_id = db_id(N'YourDB')
AND dmv1.last_user_update > STATS_DATE(ind.object_id, ind.index_id)
AND P.row_count > 0
ORDER BY STATS_DATE(ind.object_id, ind.index_id) DESC
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search