Module 5
Module 5
Maintenance
Corruption deals with accuracy and consistency.
1. SQL Server can manage itself for long periods, but what addition can DBA provide to
improve performance?
a. {{2 - - - - - - - - - - - - - - - - - -}}
2. Most important task in the ongoing maintenance schedule
a. {{3 - - - - - - - - - - - - - - - - - - - - -}}
3. What is the chief most success factor in recovering from Database corruption?
a. {{4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -}}
4. Two maintenance tasks associated with SQL Server indexes to ensure optimal
performance.
a. {{90 - - - - - - - - - - - - - - - -}}
b. {{91 - - - - - - - - - - - - - - - - - - - - - - - - -}}
5. What is the purpose of the SQL Server Maintenance Plan Wizard?
a. {{6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
DBCC CHECKDB
1. Overview of operation
a. {{26 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. Important options of DBCC CHECKDB
a. DBCC CHECKALLOC
i. {{28 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
ii. What is the allocation unit size?
1. {{27 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -}}
b. DBCC CHECKTABLE
i. {{29 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
ii. In what scenario is it automatically executed?
1. {{31 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
c. DBCC CHECKCATALOG
i. Checks the {{30 - - - - - - - - -}}
1. What is contained in this schema?
a. {{32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -}}
i. Detailed information on the various database
objects that are of interest to the system itself.
ii. Brilliant SO answer What's the difference between
a catalog and a schema in a relational database?
ii. On what does this console command perform consistency checks?
1. {{33 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
iii. What information do the metadata tables contain?
1. {{34 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
iv. Does not perform checks on user databases.
Repair Options
1. Although the DBCC provides options of repair, does it ensure complete data recovery?
a. No it does not, there is potential for data loss
2. How can DBCC be used to restore a database effectively to ensure no corruption?
a. {{35 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
3. How does the modus operandi described above ensure prevent data loss in backups
and log files?
a. {{36 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -}}
Disk Space
1. How does the usage of internal snapshots by DBCC CHECKDB increase disk space
usage?
a. DBCC CHECKDB {{42 - - - - - - -}} in the {{41 - - - - - - - - - - - - - - - - - - -}}
b. What are these files?
i. NTF{{43 - - - - - - - - -}}
ii.
The ability of NTF{{44 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -}}
c. What influences the amount of space required for DBCC CHECKDB to run
successfully?
i. The amount of {{45 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. What system database is used by the DBCC CHECKDB command during its execution?
a. {{47}}
b. What DBCC CHECKDB option can be used to estimate the space the required in
this database during its execution?
i. {{46 - - - -}}
MAXDOP Override
1. How can the MAXDOP property be used to reduce the impact of running the DBCC
utility?
a. {{50 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. What does a MAXDOP configuration value of 0 mean and how does it affect
performance?
a. {{177 - - - - - - - - - - - - - - - - - - - - - -}} potentially affecting the {{178 - - - - - - - - - -
- - - - -}}.
Types of Indexes
1. By default rows of data are stored as a heap of pages without any physical or logical
order.
a. What does lack of physical order imply in terms of storage of data pages?
i. The data pages are {{115 - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. What is the purpose of a clustered index?
a. To implement the {{116 - - - - - - - - - - - -}}.
3. A Non clustered index can be used to apply logical ordering on top of a clustered index.
What is the advantage of using this kind of arrangement?
a. Eliminates the need for {{117 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
4. Types of index
a. Clustered index has {{118 - -}} on the leaf level
b. Non clustered index has{{184 - - - - - - - -}} or{{186 - - - - - - - - - - - - - - - -}} at the
leaf level.
Clustered Index
1. Table with a clustered index has a predefined order for;
a. {{120 - - - - - - - -}}
b. {{121 - - - - - - -}}
2. Why is the key used for ordering the data pages called a clustered key?
a. The key used by the SQL Server engine to order the pages is {{122 - - - - - - - - - -
-}}.
3. Why is there only one clustered index on any given table?
a. {{123 - - - - - - - - - - - - - - - - - - -}}
b. The clustered index is the table in some ways.
4. The Allocation Unit
a. SQL Server groups all pages that belong to a single partition of a single index or
heap into logical units.
b. These units are called allocation units.
c. You can see all allocation units of the current database using the
sys.allocation_units catalog view.
5. The Index Allocation Map (IAM)
a. They are stored in special IAM pages.
b. Each IAM page covers an area of 64000 extents in a file, a so-called GAM-
interval.
c. If multiple IAM pages are needed for a single allocation unit, the form a double
linked list, the IAM chain.
6. What is the general structure of IAM used by SQL Server?
a. Entry point: {{124 - - -}} is used to point to {{125 - - - - - - - - - - - - - -}}
b. Other pages: The remaining pages are stored as a {{126 - - - - - - -}} set of
pages {{127 - - - -}} from {{187 - - - - -}}
7. At what storage level is the ordering of data within a clustered index sequential?
a. {{129 - - - - - - - - - - - - - - - - -}}
8. How does fragmentation occur in data pages?
a. When data is changed, {{128 - - - - - - - - - - - - - - - - - - - - - - - - -}} to {{188 - - -}}
in the original data page.
9. What are the demerits and merits of high levels of fragmentation?
a. Demerit: {{130 - - - - - - - - - - - - - - - - - - - - - - -}}
b. Merit: {{131 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
Index Fragmentation
1. What kinds of SQL operations cause index fragmentation over time?
a. {{204 - - - - - - - -}}
b. Remember from DML, DDL
2. For operations that read data, what condition must the pages be in to make the indexes
involved perform at their best?
a. {{205 - - - - - - - - - - - - - - - -}}
3. What causes index pages to be split?
a. When adding data to a table with {{206 - - - - - - - - - - - - - - - - -}}
b. Adding an entry to the end of an index is straightforward.
c. It is much more complicated if the entry is added {{207 - - - - - - - - - - - - - -}}.
E.g. during an update operation.
Internal Fragmentation
1. Occurs when {{209 - - - - - - - - - - - - - - -}}
a. And often when {{208 - - - - - - - - - - - - - - - - - - -}}
2. Why does this happen and what does it mean in terms of the data allocation in the
page?
a. The data could not {{210 - - - - - - - - - - - - - - - - - - - -}}.
External Fragmentation
1. Caused by DML operations that split existing pages when modifying data.
2. Process flow of how external fragmentation occurs
a. Start: Index requires {{212 - - - - - - - - - - - - - - - - - - - - - - - -}}
b. Allocation: The page to be allocated is from {{217 - - - - - - - - - - - - - - - - - - - - - -
- - - - -}}
c. Pointers: {{213 - -}} are created to {{214 - - - - - - - - - - - - - - - - - - - - - -}}.
d. Sequence: as read operations follow pointers to locate information, it means
{{215 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
Detecting Fragmentation
1. What DMV can be used to view the fragmentation in an index?
a. {{216 - - - - - - - - - - - -}}
2. What column of this view shows the measure of fragmentation in percentage?
a. {{218 - - - - - - - - - - - - -}}
Using FILLFACTOR
ALTER TABLE [Table Name]
ADD CONSTRAINT [Constraint Name]
PRIMARY KEY {{241 - - - - - - - - - - - - - -}}
WITH {{240 - - - - - - - - - - - - - -}}
Creating an Index
SQL Server CREATE INDEX By Practical Examples
CREATE INDEX [index_name]
ON sales.customers([col1],[col2]);
On-going Maintenance of Indexes
REBUILD
1. What does a REBUILD operation on an index do?
a. {{242 - - - - - - - - - - - - -}}
2. What if the effect a rebuild operation?
a. Fragmentation: {{243 - - - - - - - - - - - - - - -}}
b. Disk Space: it reclaims disk space by {{244 - - - - -}} using{{245 - - - - - - - - - - - -
- - - -}}
c. Order: {{246 - - - - - - - - - - - - - - -}}
3. What does the ALL option specify when using REBUILD on indexes?
a. {{247 - - - - - - - - - - - - - - - - - - - - - - - - - -}} as a single operation.
4. How does SQL Server react to a failure during a rebuild operation?
a. If any part of the rebuild operation fails, {{248 - - - - - - - - - - - - - - - - - -}}
5. Why do REBUILD operations use a large amount of space on the transaction log?
a. {{249 - - - - - - - - - - - - - - -}}
6. How can a DBA avoid this level logging and opt for a minimally logged one?
a. {{250 - - - - - - - - - - - - - - - - - - - - - -}}
7. What are the advantages of using a minimally logging for an operation?
a. {{252 - - - - - - - - - -}} space
b. I{{251 - - - - - - - -}} time
8. Important activities to be peformed on transactional databases after REBUILDing
indexes
a. Switch the {{253 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. Backup the database to insure against {{254 - - - - - - - - - - - - - - - - - - - - - - - - -}}
c. ?
Rebuilding an Index
{{255 - - - - - - - - - - - - - - - - - - - - - - - - - -}}
REORGANIZE
Fragmentation exists when indexes have pages in which the logical ordering, based on the key
value, does not match the physical ordering inside the data file.
1. What is the chief advantage of using this method of removing fragmentation in indexes?
a. {{256 - - - - - - - - - - - - -}}
2. What node level does this option remove fragmentation on the clustered and non
clustered indexes?
a. {{257 - - - -}}
3. How does it operate?
a. It {{258 - - - - - - - - - - - - - - - - -}}to match {{259 - - - - - - - - - - - - - - - - - - - - - -}}
4. What other operations apart from the reordering of pages occurs?
a. {{261 - - - - - - - - - - - - - - - - - - - - - -}}
5. What is the effect of an interruption to a REBUILD operation?
a. {{262 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. What advantage does this provide on large indexes?
i. DBA can configure {{263 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
6. In what scenarios is this option of removing fragmentation not used?
a. It is recommended to use REBUILD for {{264 - - - - - - - - - - - -}}
7. What options are available to a DBA to ensure the ongoing maintenance of indexes?
a. Use of {{265 - - - - - - - - - - -}}
b. Use of {{266 - - - - - - - - - - - - - - - - - - - - - - - - -}}