Fix Row Page and Counts after a Database Upgrade - SQL Server

If your databases were originally created in SQL 2000 and you plan to upgrade to SQL Server 2005/SQL Server 2008, then you should run DBCC UPDATEUSAGE

The DBCC UPDATEUSAGE reports and corrects inaccurate row and page count for tables and indexes and as a result, when you run the sp_spaceused system stored procedure, the space usage reported may be incorrect. Make sure you run DBCC CHECKDB to see if there are any problems reports (Reference)

It is advisable to run the DBCC UPDATEUSAGE command when the load on the server is not too much, although I believe the impact of running it on a ‘normal’ day traffic should not be much. As given in the BOL, here are some best practices to follow:

  • Always run DBCC UPDATEUSAGE after upgrading a database from SQL Server 2000. The page and row counts are corrected and are maintained thereafter.
  • Do not run DBCC UPDATEUSAGE routinely for databases created in SQL Server 2005 or higher or on upgraded databases that have been corrected once by using DBCC UPDATEUSAGE. Because DBCC UPDATEUSAGE can take some time to run on large tables or databases, it should not be used only unless you suspect incorrect values are being returned by sp_spaceused.
  • Consider running DBCC UPDATEUSAGE routinely (for example, weekly) only if the database undergoes frequent Data Definition Language (DDL) modifications, such as CREATE, ALTER, or DROP statements.

No comments:

Post a Comment