join the MSSQLTips community

Today's Site Sponsor


 

SQL Compare quickly and easily compares and synchronizes SQL Server database schemas
 



SQL Server performance monitoring: Idera SQL diagnostic manager

NORECOMPUTE option of UPDATE STATISTICS in SQL Server

Written By: Jeremy Kadlec -- 10/4/2006 -- read/post comments -- print -- Bookmark and Share

Rating: (not rated yet) Rate

Problem
Updating statistics is valuable for ensuring the SQL Server optimizer has the current statistical information to most efficiently process the query results.  As a best practice, the UPDATE STATISTICS command should be issued on a regular basis to provide SQL Server with the most recent data.  Automatically updating statistics is possible with the 'Auto Update Statistics' database configuration, but this could cause performance issues if a large table's statistics are updated during the middle of the day.  To prevent this problem, the 'Auto Update Statistics' option can be disabled on a per database basis. This paradigm creates the need to rebuild all of the statistics in a manual manner.  Does a happy medium exist to let SQL Server automatically manage the statistics on small tables and let me manage the statistics on the larger tables?

Solution
The simple answer is 'yes'.  SQL Server statistics can be configured on a per database basis with the ability to not automatically re-compute indexes on larger tables with the NORECOMPUTE option of the UPDATE STATISTICS command.  So let's break down the configurations and commands to make this a reality. 

Where can I find the auto update statistics option? 

SQL Server 2000 - Database Properties
SQL Server 2005 - Database Properties

How can I incorporate the NORECOMPUTE option of the UPDATE STATISTICS command in my code?

SQL Server 2000 SQL Server 2005
UPDATE STATISTICS dbo.Authors WITH NORECOMPUTE
GO
UPDATE STATISTICS dbo.Customer WITH NORECOMPUTE;
GO

Are any commands available to update the statistics in a simple manner?

SQL Server 2000 SQL Server 2005
master.dbo.sp_updatestats master.sys.sp_updatestats

How can I re-enable Auto Update Statistics once I have used the NORECOMPUTE option?

SQL Server 2000 SQL Server 2005
master.dbo.sp_autostats master.sys.sp_autostats

Next Steps

  • Review the 'Auto Update Statistics' option for your database to determine if the configurations are as expected.
  • Determine how statistics are currently being updated and how to best handle this portion of the SQL Server maintenance process.
  • If you are not currently performing SQL Server maintenance including updating the statistics, then take the time to build a maintenance process for your databases.
  • If you have Auto Update Statistics enabled on all of your large databases and are not experiencing any issues consider re-evaluating this approach and use the NORECOMPUTE option of the UPDATE STATISTICS command for the large tables and let SQL Server maintain the statistics for the small tables.
  • Thank you to Armando from the MSSQLTips.com community for sharing this tip idea.  If you would like to share tips of your own, please email your ideas to tips@mssqltips.com.
Readers Who Read This Tip Also Read Free Live Webcast Comment or Ask Questions About This Tip



Get Our Tips Newsletter

We keep 50,000+ SQL Server professionals informed.



Red Gate Software - SQL Backup

Need to create smaller, more reliable backups? Ensure your backups are optimized for robustness and speed with Red Gate SQL Backup Pro. Compress your backups by up to 95% and minimize disruptions to your backups caused by flaky networks with new network resilience. 'Network resilience puts SQL Backup Pro 6 at the top of the list of backup tools. It’s the cherry on top, and I definitely recommend using SQL Backup over SQL Server 2008 native backups.' William Durkin, Development DBA. Download now.

Download now!

More SQL Server Tools
SQL Prompt

SQL comparison toolset

SQL compliance manager

SQL Backup

SQL safe backup


Sponsor Information
Free SQL Server performance monitoring dashboard – Idera SQL check

Try SQL Object Level Recovery Native from Red Gate to save time and disk space. Download a free trial.

Make the most out of SQL Server - Guaranteed Results - Innovative SQL Server DBAs

Stop here to prepare for your next SQL Server interview!

Learn SQL Server 2008, Performance Tuning, Development, Administration, DR, Replication and more from these web casts



Copyright (c) 2006-2010 Edgewood Solutions, LLC All rights reserved
privacy statement | disclaimer | copyright | advertise | write for mssqltips | feedback | about
Some names and products listed are the registered trademarks of their respective owners.


CareerQandA.com | MSSharePointTips.com | MSSQLTips.com