Download DBCC CHECKDB In`s and Out`s

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Consistency model wikipedia , lookup

Oracle Database wikipedia , lookup

Microsoft Access wikipedia , lookup

Tandem Computers wikipedia , lookup

Database wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Team Foundation Server wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Database model wikipedia , lookup

Open Database Connectivity wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Transcript
DBCC CHECKDB IN’S
AND OUT’S
HENRY SINCLAIR
ABOUT ME
• SQL Server DBA Skilled in Real World Operational and
Warehouse Systems
• Microsoft SQL Server PFE
• SQL Server Community Contributor
• Experienced SQL Server management from SQL Server
Internals to Full-Feature Utilization
• Blogger at SQLBEATS.com
• Twitter handle @sqlbeats
INTRODUCTION
• Why run DBCC CHECKDB
• What causes Corruption
• CHECK DB Tasks
• What does CHECKDB DO ?
• Key CHECKDB Parameters
• Improve performance for VLDB’s
• Potential Issues
WHY RUN DBCC CHECKDB
• We are Data Professionals
• Part of a DBA’s Job
• Ensure Data Consistency
• Could cost you your job
WHAT CAUSES
CORRUPTION
• Majority of Corruption is I/O Subsystem
• Memory Corruption
• SQL Server Bugs
• Human Error
CHECKDB TASKS
• DBCC CHECKALLOC
• DBCC CHECKTABLE
• DBCC CHECKCATALOG
• Checks metadata
• File system directories/files for FILESTREAM
• Checks Service Broker structures
WHAT DOES CHECKDB DO (1) ?
• Creates a Hidden Snapshot using NFTS Alternate Streams
• Alternate Streams Not used in SQL 2014
• Primitive System Table Checks
• Any Errors shall require restore or manual data extraction
• Allocation Consistency Checks
• DBCC CHECKALLOC
• Logical Consistency Checks
• DBCC CHECKTABLE
•
•
Critical System Tables
All Other Tables
WHAT DOES CHECKDB DO (2) ?
• Metadata checks
• DBCC CHECKCATALOG
• Optional Checks
• FILESTREAM
• Service Broker Validation
• Extended_Logical_Checks
•
•
•
XML Indexes
Spatial indexes
Optional from SQL 2008 Onwards
DBCC CHECKDB OPTIONS (1)
• Repair Options
• REPAIR_ALLOW_DATA_LOSS
• REPAIR_FAST
• REPAIR_REBUILD
• EXTENDED_LOGICAL_CHECKS
• Extra Validation against indexed Views, XML indexes and
Spatial Indexes
• TableResults
• Undocumented command, but Safe to use
DEMO
Database Corruption of NonClustered Index and
REPAIR_REBUILD
DEMO
Database Corruption of
Clustered Index and
REPAIR_ALLOW_DATA_LOSS
DBCC CHECKDB OPTIONS (2)
•
NO_INFOMSGS
•
• Skips Printing informational messages
TABLOCK
•
• Uses Locks rather than snapshot
• Requires Exclusive Database Lock for Allocation Checks
• Default for Tempdb
DATA_PURITY
•
•
Default on all Databases created on SQL 2005 Higher
Except Master and Model due to Bug
•
•
http://www.sqlskills.com/blogs/paul/bug-dbcc-checkdb-datapurity-checks-are-skipped-for-master-and-model/
ESTIMATEONLY
•
Estimate space required by Tempdb
DEMO
Data Purity Bug and how to
Identify
IMPROVE PERFORMANCE
• Breakup Consistency Checks
• DBCC CHECKFILEGROUP and DBCC CHECKCATALOG
• DBCC CHECKTABLE Plus DBCC CHECKALLOC and
DBCC CHECKCATALOG
• Restore backup to another Server
• Use with TABLOCK
• Potentially not feasible
• Review MAXDOP setting
• http://www.sqlskills.com/blogs/paul/dbcc-checkdbscalability-and-performance-benchmarking-on-ssds/
IMPROVE PERFORMANCE(2)
• Consider reducing Memory available to CHECKDB
• http://www.sqlskills.com/blogs/jonathan/dbcc-checkdbexecution-memory-grants-not-quite-what-you-expect/
• Consider Disabling/Dropping Certain Non-Clustered
Indexes
• On Computed Columns
• http://www.sqlskills.com/blogs/paul/dbcc-checkdbperformance-and-computed-column-indexes/
• Filtered Indexes on Sparse Columns
• http://sqlblog.com/blogs/argenis_fernandez/archive/2013/0
6/16/dbcc-checkdb-on-vvldb-and-latches-or-my-pain-isyour-gain.aspx
POTENTIAL ISSUES
• Watch out for Longer run times
• CHECKDB consistency checks use TempDb
• DB Snapshot runs out of Space
• No Permissions
• Heavily Fragmented System
• http://support.microsoft.com/kb/2002606
QUESTIONS