This is very ineteresting topic and might be helpful ..
i see some people enable AUTO create and UPDATE statistics on each database.
and some people enable AUTO create statistics but disable UPDATE statistics ..
there are pros and cons for each of them , but i want to focus on databases whose UPDATE Statistics is not enabled ....
We need to update the statistics at least 1 time a week, as statistics provide good useful info ( road map ) for optimizer to choose which path to go ..
SQL Server uses statistics to react intelligently in its query optimization
Statistics are automatically created for each index key we create
Check Statistics info:
SELECT LastTimeUpdated = STATS_DATE(si.id, si.indid)
,TableName = object_name(si.id)
,StatisticsName = RTRIM(si.name)
,Size = DATALENGTH (si.statblob)
FROM sysindexes si WITH (nolock)
WHERE OBJECTPROPERTY(si.id, N'IsUserTable') = 1
order by LastTimeUpdated, tablename
---update all ststistics each database at a time
EXEC sp_updatestats
---- Clears the procedure cache for the entire server
DBCC FREEPROCCACHE
---
-- Update all usage in the database
DBCC UPDATEUSAGE (0);
NOTE:Update statistics after rebuilding indexes as Index rebuild will automatically Update statistics for index...
No comments:
Post a Comment