Professional Documents
Culture Documents
20765C 05
20765C 05
• Physical integrity
• Data pages are written to physical storage as SQL Server
requested and can be read correctly
• Logical integrity
• The data within the pages is logically correct so that they
can refer to each other as required to instruct SQL Server to
fetch related pages
Overview of DBCC CHECKDB
Option Description
PHYSICAL_ONLY Only checks the physical integrity to
reduce overhead
NOINDEX Does not perform logical checks on
nonclustered indexes
EXTENDED_LOGICAL_CHECKS Performs additional logical checks of
indexed views, spatial, and XML
indexes
TABLOCK Uses locks instead of database
snapshots
ALL_ERRORMSGS Returns all error messages instead of
the default action that returns the first
200
NO_INFOMSGS Returns only error messages and no
informational message
ESTIMATEONLY Estimates the amount of tempdb space
that it requires to run
DBCC CHECKDB Repair Options
• Table Scan
• SQL Server reads all data pages
• Index
• SQL Server uses index pages to find rows
Types of Indexes
Root Node
Intermediate
Level Nodes
Leaf-Level Nodes/
Data Pages
Dynamic Management Objects
• Categories of DMO
• Index-Related DMOs
• sys.dm_db_index_usage_stats
• sys.dm_db_index_operational_stats
• sys.dm_db_index_physical_stats
• sys.dm_db_missing_index_details
Index Fragmentation
• Detecting fragmentation:
• Index properties in SQL Server Management Studio
• sys.dm_db_index_physical_stats
FILLFACTOR and PAD_INDEX
• Rebuild:
• Rebuilds the whole index
• Needs free space in database
• Performed as a single transaction with potential
requirement for a large amount of transaction log space
ALTER INDEX CL_LogTime ON dbo.LogTime REBUILD
• Reorganize:
• Sorts the pages and is always online
• Less transaction log usage
• Can be interrupted but still retain work performed to
that point
ALTER INDEX ALL ON dbo.LogTime REORGANIZE;
Online Index Operations
Option Description
AUTO_CREATE_STATISTICS Database options that enable SQL
AUTO_UPDATE_STATISTICS Server to automatically
create/update statistics
Statement that updates all statistics
UPDATE STATISTICS
on a table or specified subset of
<table>
statistics on demand
System stored procedure that
SP_UPDATESTATS
updates all statistics in a database
Demonstration: Maintaining Indexes
Logon Information
Virtual machine: 20765C-MIA-SQL
User name : ADVENTUREWORKS\Student
Password: Pa55w.rd