Update statistics on all tables of a database
One of the quick and efficient ways to troubleshoot performance problem of a slow database is updating statistics (If it is slow for outdated statistics which typically causes from data change). It is normally safe to use this procedure in a production database during business hour as it is online operation with minimum overhead. Also in most cases, it provides significant performance improvement with out executing heavy-weight operations like index rebuild etc. (However it does not replace the need of index maintenance or rebuild as it does not do anything with indexing)
If you want to update all statistics for a particular database, then use sp_updatestats.
Syntax:
USE [DatabaseName];
GO
EXEC sp_updatestats
However it will update only the statistics that require updating based on the rowmodctr information in thesys.sysindexes catalog view, thus avoiding unnecessary updates of statistics on unchanged rows..
sp_updatestats displays messages that indicate its progress. When the update is completed, it reports that statistics have been updated for all tables. Also it updates statistics on disabled nonclustered indexes and does not update statistics on disabled clustered indexes.
Comments