Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

592


Part V: Enterprise Data Management


DBCC results for 'Production.TransactionHistoryArchive'.
There are 89253 rows in 620 pages for object
"Production.TransactionHistoryArchive".
CHECKDB found 0 allocation errors
and 0 consistency errors in database 'AdventureWorks2012'.
DBCC execution completed. If DBCC printed error messages, contact
your system administrator.

Best Practice


Since SQL Server 7.0, the storage engine quality has signifi cantly improved, reducing the need for
running DBCC CHECKDB frequently. However, a full proof recovery plan includes a full restore and a
DBCC CHECKDB to make sure all the portions of the recovery plan work. The frequency to run a DBCC
CHECKDB often depends on your comfort level, your environment, and the importance of your data.
(The authors would never say that DBCC CHECKDB is not needed. It is recommended to run it now
and then as well as restoring from backups.) You should also run DBCC CHECKDB after any hardware
malfunction. If an error is detected, restore from a known good database backup. As mentioned,
use the repair option only as the last option. If DBCC CHECKDB asks you to use REPAIR_ALLOW_DATA_
LOSS, take a full database backup fi rst, and then run DBCC CHECKDB with the repair option in a user
transaction. That way you can verify the data loss after the command is executed and roll back the
transaction if the data loss is not acceptable. After successfully repairing the database, take a full
database backup.

As DBCC CHECKDB is a resource-intensive operation, run it during low peak hours.

Multi-User Concerns
DBCC CHECKDB without any repair option can be executed while users are in the
database. However, DBCC CHECKDB is processor- and disk-intensive, so run it when the
database has the fewest users. By default, DBCC CHECKDB can check objects in paral-
lel across all CPUs in the box, which can boost the performance of DBCC CHECKDB and
reduce the run times. The degree of parallelism is determined by the SQL Server query
processor, and the algorithm used is similar to running parallel queries. Because running
DBCC CHECKDB in parallel is processor-intensive, you may have environments or situa-
tions in which you want to disable parallel checking of objects by DBCC CHECKDB. SQL
Server enables you to disable parallel checking of objects by DBCC CHECKDB by using the
trace fl ag 2528.

Object-Level Validation
DBCC CHECKDB performs a host of database structural-integrity checks. You can run these
checks individually. For example, if you have a large database (VLDB), it may not be pos-
sible to run DBCC CHECKDB on the entire database, but you may run individual checks on
key database objects.

c22.indd 592c22.indd 592 7/31/2012 9:24:30 AM7/31/2012 9:24:30 AM


http://www.it-ebooks.info
Free download pdf