• SQL Server
  • Log Shipping Tricks Demo
  • SQLCruise Alaska 2012 Pics
SQLSoldier News From the Frontlines

SQLU VLDB Week – Integrity Checks

April 14, 2011 9:18 pm / 2 Comments / SQLSoldier

SQLU VLDB Week – Integrity Checks

SQL University

SQL U - VLDB Week


Welcome back to day four of VLDB week at SQL University. Today, we will talk about running integrity checks – a.k.a. DBCC CHECKDB. In factuality, there are serveral DBCC CHECK commands for checking database integrity, not just CHECKDB. CHECKDB is the main function, the grandaddy of all DBCC CHECK commands. It is the one that performs the full gamut of integrity checks on a database.

Almost everything I know about CHECKDB I learned from Paul Randal (blog|@PaulRandal), either in one of the many SQLSkills.com classes I have attended or by reading material he has written on on his blog. This is especially true for CHECKDB on a VLDB. I would definitely be remiss if I didn’t call out that just about all knowledge I share on this page, I learned from Paul.

With integrity checks on VLDBs, we run into the same kind of challenges we see with just about everything else. It takes too much time. It uses too many resources. I have also heard from many people that they are concerned with running out of disk space due to the database snapshot it creates. Well fear not!! As with everything else we have discussed this week, we have some tips for you.

Run CHECKDB on a Restored Backup

This is my preferred method for handling integrity checks on a VLDB, if you have the infrastructure to support. Database mirroring and log shipping do not transfer corruption if it exists. A database backup will transfer corruption. If we restore the full backup that was created on a corrupt database, the restored database will be corrupt as well.

I used to perform operations for a VLDB that had two replica servers used by downstream consumers of the data (ETL) and ad hoc reporting users who had data freshness SLAs that could not be met by our data warehouse. The replica servers were load balanced, and users connected to a virtual name. We could move them to one server or the other as needed or let the load be balanced across both. The plan I wrote was to remove one of the replica servers from load balancing, drop replication, restore the full backup to it, run CHECKDB on it, rebuild replication, and then add the serverback into load balancing. With little effort, it’s a process that can be automated to run over a weekend when usage of the replicas is lower.

The downside of this is that the time it takes to copy the file, restore it, and run CHECKDB is a long time, and can lengthen the time until discovery of corruption.

Run with the PHYSICAL_ONLY option

Running CHECKDB WITH PHYSICAL_ONLY will perform a check of the physical structures of the pages and record headers and will check the integrity of the allocations. This check is limited, but among the things it detects are torn pages, checksum failures, and some hardware failures that can threaten the integrity of your database. This mode skips many of the checks that the full CHECKDB runs and can run a lot faster though it is limited in scope and leaves lots of openings for corruption to go undetected. It’s still better than nothing.

Break it up into Smaller Parts

This is where I recommend referring to Paul Randal’s post CHECKDB From Every Angle: Consistency Checking Options for a VLDB. Paul lays out everything out and explains how the process can be broken apart.

There are two approaches you can take here. One approach is to break CHECKDB apart according to filegroups and run DBCC CHECKFILEGROUP on different filegroups each night. Another approach is to break it apart into specific buckets of tables using DBCC CHECKTABLE along with running DBCC CHECKALLOC and DBCC CHECKCATALOG. If considering one of these approaches, you should read Paul’s post referenced above to ensure you are covering everything that needs to be covered.

Posted in: SQL Server / Tagged: Disaster Recovery, Internals, Performance & Optimization, SQL University, Tips & Tricks

2 Thoughts on “SQLU VLDB Week – Integrity Checks”

  1. Thomas LeBlanc on April 15, 2011 at 6:26 am said:

    I have done the break done into CheckTable with CheckAlloc and CheckCatalog. We use a some on number of rows count, and stop CheckTable when a threshold is it. The congiuration and last table is in our Operations database on the instance.

    We only use this on Large DBs.

    Thomas

    Reply↓
    • SQLSoldier on April 15, 2011 at 6:29 am said:

      Thanks Thomas!! It’s helpful to hear about real life usage stories!!

      Reply↓

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation

← Previous Post
Next Post →
<

Remote DBA Services
- serious SQL Server expertise for less than a full-time DBA
My Articles
 
My Book
Check out my interview on

Extreme Data Recovery (with Argenis Fernandez)
10 Things all BI System Administrators Should Know
Upcoming Events
    All events shown in Pacific Time

    No events to show

RSS My SQL Server Magazine Articles

  • Database Mirroring for Disaster Recovery September 16, 2011
  • Comparative Review: Database Schema Comparison Tools August 24, 2011
  • 3 Log Shipping Techniques June 22, 2011
  • Hardening SQL Server June 20, 2011
  • Review: ScriptLogic Security Explorer for SQL Server February 8, 2011

Tags

31 Days of Disaster Recovery Architecture Automation CDC & Change Tracking Data Architecture VC Database Mirroring DBCC Denali Disaster Recovery Dynamic Management Views Extended Events Gamers & Geeks General Discussion High Availability How do I ... ? Humor Idera ACE Program Internals MCM Meme Monday Performance & Optimization PowerShell Professional Development Replication Security SQLBits SQL PASS SQL PASS Summit SQLRally SQL Saturday SQL Server Magazine SQL University SSAS & BI SSIS SSMS SSRS T-SQL T-SQL Tuesday tempDB Tips & Tricks Travel Troubleshooting Undocumented Stuff Whitepapers XML in SQL

News

Download my Powershell Scripts

The following scripts can be downloaded as text files. You will need to change the file extension to .ps1 in order to execute them.

Backup a database
Restore a database
Scan a server to find a free port
Query DNS to get the FQDN of a server


To see some examples of my other forms of writing, please visit my page on WritersCafe.org. It is almost exclusively horror fiction, but I sometimes throw other things in there too from time to time. There's one science fiction story, a couple of poems, and quite a few humor pieces as well.


Look for me in the SQL Q&A section of the August, 2007 issue of TechNet Magazine.
August issue of TechNet Magazine's SQL Q&A column

Protect our Heroes

© Copyright 2012 - Robert L Davis
Infinity Theme by DesignCoral / WordPress

Twitter Twitter 
LinkedIn LinkedIn 
TLF TLF RSS RSS 
WritersCafe WritersCafe 
SQLPASS SQLPASS 
Facebook Facebook
grab this