Answered by:
Update Statistics

Question
-
How to update statistics on entire DATABASE ?
Thursday, September 5, 2013 5:36 AM
Answers
-
"thus avoiding unnecessary updates of statistics on unchanged rows"
But there's a huge difference between "unchanged" and 20% or more modified. Say you have 10,000,000 rows. You have had to do 2,000,000 modifications for the column(s) in order for sp_updatestats to update the statistics. That is a lot, IMO. I generally use Ola's IndexOptimize and specify it to update if > 0 rows has been modified. :-)
- Marked as answer by VijayKSQL Thursday, September 5, 2013 12:37 PM
Thursday, September 5, 2013 11:08 AM
All replies
-
Hello Vijay,
Instead of updating stats for entire database I would suggest you to choose tables which are heavily updated and inserted or deleted .Updating stats for whole DB might cause job to run long and some blocking issues
You can run below command for particular database.
execute sp_updatestats
http://msdn.microsoft.com/en-us/library/ms173804.aspx
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
- Proposed as answer by Ramesh Babu Vavilla Thursday, September 5, 2013 11:25 AM
Thursday, September 5, 2013 5:46 AM -
EXEC sp_updatestatsPlease refer the below link:http://technet.microsoft.com/en-us/library/ms187348.aspx
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
- Proposed as answer by Ramesh Babu Vavilla Thursday, September 5, 2013 11:25 AM
Thursday, September 5, 2013 5:46 AM -
IN addition you can see this link to update statistics on all databases:
Execute UPDATE STATISTICS for all SQL Server Databases
The most important motivation for the research work that resulted in the relational model was the objective of providing a sharp and clear boundary between the logical and physical aspects of database management. - E. F. Codd
My blog- Proposed as answer by Ramesh Babu Vavilla Thursday, September 5, 2013 11:25 AM
Thursday, September 5, 2013 5:56 AM -
Here is an other script from MS TechNet Script Center: Update out-dated statistics
Or you can use a maintenance plan with a Update Statistics Task (Maintenance Plan)
Olaf Helper
[ Blog] [ Xing] [ MVP]Thursday, September 5, 2013 6:17 AM -
Hi Vijay,
You can refer this Link : http://sqlserverplanet.com/dba/update-statistics
Hope it will help
Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you.
Thursday, September 5, 2013 6:27 AM -
The script we use on many SQL Server boxes for index and statistics maintenance is written by Ola Hallengren and can be found at http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html.
Regards, Dean Savović
Thursday, September 5, 2013 6:32 AM -
Note that my testing show that sp_updatestats do not update statistics for the whole database. Rather, it uses the same "if more than 20% of data has been modified" as the database auto update statistics setting does. I.e., my experience is that this procedure is not useful.Thursday, September 5, 2013 10:56 AM
-
Note that my testing show that sp_updatestats do not update statistics for the whole database. Rather, it uses the same "if more than 20% of data has been modified" as the database auto update statistics setting does. I.e., my experience is that this procedure is not useful.
Hello Tibor,
Agre with you but what exactly you mean by ''if more than 20% of data has been modified" sp_updatestats updates only the statistics that require updating based on the rowmodctr information in the sys.sysindexes catalog view, thus avoiding unnecessary updates of statistics on unchanged rows.
Thanks
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
- Edited by Shanky_621MVP Thursday, September 5, 2013 11:34 AM typo
Thursday, September 5, 2013 11:05 AM -
"thus avoiding unnecessary updates of statistics on unchanged rows"
But there's a huge difference between "unchanged" and 20% or more modified. Say you have 10,000,000 rows. You have had to do 2,000,000 modifications for the column(s) in order for sp_updatestats to update the statistics. That is a lot, IMO. I generally use Ola's IndexOptimize and specify it to update if > 0 rows has been modified. :-)
- Marked as answer by VijayKSQL Thursday, September 5, 2013 12:37 PM
Thursday, September 5, 2013 11:08 AM