0% found this document useful (0 votes)
15 views

Module 5

This document provides an overview of performing database maintenance in SQL Server. It discusses topics like database corruption, integrity checks, the DBCC CHECKDB command, repair options, and online maintenance operations. DBCC CHECKDB is used to detect and report errors and ensure physical and logical integrity. It can check entire databases or individual filegroups. Running regular integrity checks is important to detect issues early and prevent data loss. Maintaining indexes and backing up databases also supports integrity. The MAXDOP option can control resource usage during maintenance tasks.

Uploaded by

andrew.ouko.254
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Module 5

This document provides an overview of performing database maintenance in SQL Server. It discusses topics like database corruption, integrity checks, the DBCC CHECKDB command, repair options, and online maintenance operations. DBCC CHECKDB is used to detect and report errors and ensure physical and logical integrity. It can check entire databases or individual filegroups. Running regular integrity checks is important to detect issues early and prevent data loss. Maintaining indexes and backing up databases also supports integrity. The MAXDOP option can control resource usage during maintenance tasks.

Uploaded by

andrew.ouko.254
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Module 5: Performing Database

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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}

Lesson 1: Ensuring Database Integrity


1. DB corruption directly is rare, which layer causes corruption?
a. {{7 - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. In the above layer/platform which subsystems cause corruption? (2)
a. {{92 - - - -}}
b. {{93}}
3. Explain why it is prudent to detect corruption early and prevent further issues?
a. {{9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -}}
4. Console command to detect database corruption
a. {{10 - - - - - - -}}

Introduction to Database Integrity


1. Name the two levels of Database integrity
a. {{11 - - - - -}}
2. What does physical integrity ensure?
a. {{12 - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
3. What does logical integrity ensure?
a. {{13 - - - - - - - - - - - - - - - - - - -}}
b. What does logically correct mean in terms of data pages?
i. {{14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
ii.
Using the relationship between indexes and data rows describe how this
is implemented.
1. {{15 - - - - - - - - - - - - - - - - - - - - - -}}
2. {{16 - - - - - - - - - - - - - - - - - - - -}}
iii. What happens when data rows don’t have an index entry?
1. {{17 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -}}
4. What is the main risk of not regularly checking database files for lack of integrity?
a. {{18 - - - - - - - - - - - - - - - - - - - - - - - - -}}
5. Backups do not check for integrity, but what option do they provide for checking
consistency?
a. CHE{{40}}
i. Define it
1. {{21 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. Is this option provided by default?
i. {{19 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
c. When is the CHECKSUM checked by SQL Server?
i. {{20 - - - - - - - - - - - - - - - - - - - - -}}
ii. What is the exception to this?
1. When SQL Server is backing up the database WITH
CHECKSUM option turned on.
6. What are two common usage scenarios that can lead to corruption?
a. {{22 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. {{23 - - - - - - - - - - - - - - - - - - - - - - -}}

Overview of DBCC CHECKDB


1. What name did it used to go by initially?
a. {{24 - - - - - - - - - - - -}}
2. What name is currently used to signify the wide range of tasks supported?
a. {{25 - - - - - - - - - -}}

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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -}}

Online Concurrent Operations


1. Why is the DBCC CHECKDB run while the database is still in use? (3)
a. {{37 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. How does the DBCC CHECKDB command maintain a consistent view of the db if it
operates while the db is in use?
a. {{38 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
3. What is the ideal alternative in scenarios where the performance requirements for having
database activity ongoing while the DBCC CHECKDB is executing is too high?
a. {{39 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. Better than not running it all.

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 - - - -}}

Backup and DBCC CHECKDB


1. Why is it important to run DBCC CHECKDB before taking a backup?
a. {{48 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. In systems that are used 24/7, what modus operandi can be used to check for
consistency without affecting their performance?
a. Run the command {{49 - - - - - - - - - - - - - - - - - - - - -}}

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 - - - - - - - - - -
- - - - -}}.

DBCC Check FileGroup


1. What does this command run consistency check on?
a. {{52 - - - - - - -}}
2. Potential advantage of using this?
a. {{53 - - - - - - - - - - - - - - - - - - - - - - - - -}}
3. When is this option available to a DBA?
a. {{54 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
4. What sys object can be used to check the usage of files and filegroups?
a. {{55 - - - -}}
5. If the query returns PRIMARY, the command will only be run on the primary device
as no other filegroups exist.
a. This is a non-optimal physical environment.

DBCC CheckDB Options


1. Physical Only
a. What does it check and why?
i. {{56 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. Why do DBAs use this option?
i. {{57 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
c. When you run this option regularly, you will still have to run the full option
periodically depending on the business requirements.
2. No index
a. What do Clustered and Non clustered index actually mean?
b. What does it perform/not perform checks on?
i. {{58 - - - - - - - - - - - - - - - - - - - - - - -}}
c. How does this affect execution time? System tables?
i. It reduces the {{180 - - - - - - - - - - - - - - - - -}} but integrity is still verified
for {{179 - - - - - - - - - - -}}.
d. What assumption does a DBA make when using this option?
i. {{61 - - - - - - - - - - - - - - - - - - - - - - - -}}
3. EXTENDED_LOGICAL_CHECKS
a. What objects does this option perform checks on?
i. Indexed views,
ii. {{60 - - - - - -}}
1. Geographical location information of a point
iii. XML indexes
iv. {{62 - - - - - - - -}}
1. CLR User-Defined Types - ADO.NET
4. TABLOCK
a. What does this option request DBCC to do?
i. {{63 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. What is the benefit of this?
i. {{64 - - - - - - - - - - - - -}}
c. What are the risks of using this?
i. {{65 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
5. ALL_ERRORMSGS
a. What is the default output action for messages during the execution of the
command?
i. {{66 - - - - - - - - - - - - -}}
b. What does this option do?
i. {{67 - - - - - - - - - - - -}}
6. NO_INFOMSGS
a. {{68 - - - - - - - - - - - - - - - - - - - - - -}}
7. ESTIMATEONLY
a. What does this option do?
i. {{69 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. What can this help a DBA prevent?
i. {{70 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
DBCC CheckDB Repair Options
1. What is the recommended cause of action in case of database corruption?
a. {{73 - - - - - - - - - - - - - -}} rather than {{74 - - - - - - -}}
2. Why is repairing the database a last resort in the case of corruption?
a. {{72 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
3. Steps to take when repairing a database?
a. {{75 - - - - - - -}} if possible
b. {{76 - - - - - - - -}}
c. {{77 - - - - - - -}}
4. How can I DBA identify the apt repair option?
a. {{78 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
5. Constraint for the database mode using the repair option
a. Database must be in {{79 - - -}} mode
6. Repair options
a. REPAIR_BUILD
i. What does this option do to repair a corrupt database?
1. {{80 - - - - - - - - - - - - - - - - - - - - - - - - -}}
ii. Best scenario to use this.
1. {{81 - - - - - - - - -}}
iii. Advantage
1. {{82 - - -}}
b. REPAIR_ALLOW_DATA_LOSS
i. How does this repair option work?
1. {{83 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-}}
ii. What is the expected level of consistency after running this operation?
1. {{84 - - - - - - - - - - - - - -}}
iii. Expected risk after running this operation
1. {{85 - - - - - - - -}}
iv. It does not check the constraints that exist between tables.
v. What command can be run to check the constraints between tables after
running the repair operation?
1. {{86 - - - - - - - -}}
vi. Example in the text
c. What repair options are available if the transaction log becomes corrupt and no
backups are available?
i. {{89 - - - - - - - -}}
d. How do you run this mode?
i. Run {{87 - - -}} with the {{88 - - - - - - - -}} option.
Lesson 2: Maintaining Indexes
1. What does the database engine use indexes for?
a. To optimize{{175 - - -}} of {{181}} stored in {{182 - - - - - -}}.
2. Why do indexes need to be maintained after continuous use?
a. {{96 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
3. How does this fragmentation affect performance?
a. {{97 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
4. What other additional techniques aside from the rebuilding of indexes, can be used to
improve database storage access performance?
a. {{98 - - - -}}
b. {{99 - - - - - - - - -}}

How Indexes Affect Performance


1. Methods used by SQL to access data in a table.
a. Table Scan: definition
i. {{100 - - - - - -}}
b. Index: definition
i. {{101 - - - - - - -}} (place pointer in a certain position) to {{103 - - - - - - - -
-}}
ii. Reduces the{{183 - - - - - - - - - - - - - - - - - - - - - -}}
c. Major difference between the two when reading from a table multiple times
i. {{104 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
2. Performance advantages of using indexes, Faster operations for;
a. {{105}}
b. {{106 -}}
c. {{107}}
3. Additional overheads incurred when using indexes.
a. {{108 - - - - - - - - - - - - -}}
b. {{109 - - - - - - - - - - - -}}
4. How does SQL Server automatically use indexes to improve performance?
a. {{110 - - - - - - - - - -}} creates {{112 - - - - -}} when it calculates that this can {{113
- - - - - -}}.
5. What is the chief most consideration for DBA after spotting the automatically created
indexes?
a. To decide whether {{114 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -}}

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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}

Non clustered index


A nonclustered index sorts and stores data separately from the data rows in the table. It is a
copy of selected columns of data from a table with the links to the associated table.
1. If the table does not have a clustered index underlying it, how is the data stored by SQL
Server?
a. The data is stored as a {{189 - - - - - - - - - -}} / allocation units - allocated by
{{133 - - - - - - - - - - - -}}.
2. What does the leaf level of a non clustered index contain?
a. {{134 - - - - - - - - - - - - - - -}}
3. What do these objects reference?
a. Where the {{135 - - - - - - - - - - - -}} for a given object.
b. The {{136 - - - - - - - - - - - - - - - - - - - -}} for a given object.
4. A pointer has the following attributes
a. {{137}} number
b. {{138}} number
c. {{139 - -}} on the page

How Indexes Are Used


1. Process flow for the searching a particular ID entry in an index of the ID column.
a. Root level
i. {{140 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -}}
b. Next level
i. {{141 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
c. Next level
i. {{142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -}}
d. Stopping point
i. {{143 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
e. Leaf level nodes
i. Leaf level nodes are the {{190 - - - - - - - - - - - - - - - - - - - - - - - -}}
ii. With a clustered index the leaf level of pages also contains the {{145 - - - -
-}} of the table - in addition to the IAM Pages.
2. Index and data pages are linked and double linked with a logical hierarchy across all
pages in the same level of the hierarchy. How does this help SQL Server to data
faster?
a. SQL server can perform {{146 - - - - - - - -}} across an index from a {{147 - - - - -}}
that is located using {{149 - - - - -}}
Other Types of Indexes
1. Integrated Full-Text Search (IFTS)
a. Special type of index that provides the {{148 - - - - - - - - - -}}
2. Geometry and Geography
a. Use {{150}} indexes
3. Primary and Secondary XML Indexes
a. Useful for querying {{151 -}}
4. Columnstore indexes
a. Columnstore indexes: Overview - SQL Server
b. Used by {{152 - - - -}} and {{153 - - - - - - - -}}
c. A columnstore index is a type of data structure that's used to store, manage and
retrieve data that is stored in a columnar-style database.
d. Columnstore indexes work well with read-only queries and large-scale
analysis.

Dynamic Management Objects


1. What are the Dynamic Management Objects?
a. {{154 - - - - - -}} that can be examined using {{155 - - -}} like other database
objects e..g {{156}}, {{157}} and {{158 - - - - -}}.
2. What information about the server is contained in these objects?
a. {{159}} information
b. {{160 -}} information
3. Types of DMO
a. {{161 - - - - - - - - - - - -}}
b. {{162 - - - - - - - - - - - - - -}}
4. How to use;
a. DMV
i. {{163 - - -}} statement similarly to user defined VIEWS
b. DMF
i. Query the same way you would a {{191 - - - - - - -}}
ii. SQL Server Table-Valued Function By Practical Examples
5. Categories of DMOs
a. Database Related DMVs
i. Provide information about the {{167 - - - - - - -}}.
ii. Example {{165 - - - - - - - - - -}} which shows how each file in the
database uses disk space.
b. Server Related DMOs
i. DMVs and DMFs that show {{168 - - - - - - - - - - -}} and the {{169 - - - - - - -
- -}}.
ii. Example {{170 - - - - - - - -}} which shows information about the status
and configuration of services e.g. Full Text Search Service, SQL
Server Agent etc.
c. Transaction Related DMOs
i. DMVs and DMFs that provide information about the {{171 - - - - - - - - - - -
- - - - - - - - -}}.
ii. {{172 - - - - - - - - - - - -}} show information all active transactions on the
server
d. Security Related DMOs
i. These DMFs and DMVs provide information on the {{173 - - - - - - - - - - - -
- - - -}}.
ii. Sys.dm_database_encryption_keys DMV provides information on the
{{174 - - - - - - - - - - - - - - - - - - - - - -}}.
6. Full list of system DMVs Dynamic Management Views (Transact-SQL) - SQL Server
7. Note the prefixes in the sys.dm_[db/server/null/db_index]_[method]

Index Related DMOs


1. Al have dm_db_index
2. Sys.dm_db_index_usage_stats
a. Shows information on the {{192 - - - - - - - - - - - - - -}}
b. And {{193 - - - - - - - - - - - - - - - - - - - -}}
3. {{194 - - - - - - - - - - - - -}}
a. Returns the following current activity information for each index in the database
i. {{195}}
ii. {{197}}
iii. {{198 -}}
iv. {{199 - - -}}
4. Sys.dm_db_index_physical_stats
a. Returns information on the {{200}} and {{201 - - - - - - - - -}} for a specified {{202 -
- -}}.
5. {{203 - - - - - - - - - - - -}}
a. Returns information about missing indexes.

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 - - - - - - - - - - - - -}}

Retrieving the Physical Fragmentation Details of a Database


sys.dm_db_index_physical_stats (Transact-SQL) - SQL Server
Inside The Storage Engine: GAM, SGAM, PFS and other allocation maps - Paul S. Randal
SELECT * FROM
sys.dm_db_index_physical_stats
(
DB_ID([db_name]) → {{219 -}}
,OBJECT_ID([Db.Table]) → {{220 - - - - - - -}}
,NULL → {{222 - - - -}}
,NULL → {{221 - - - - - - - - - - - - - - -}}
,’DETAILED’ → This is the {{223 - - -}} (LIMITED - {{224}}, DETAILED - {{225 - - - -}} or
SAMPLED)
);

SELECT DB_NAME([database id])


, OBECT_NAME([Object ID])
, avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DEFAULT, DEFAULT, DEFAULT, DEFAULT,
DEFAULT)
FILLFACTOR AND PAD_INDEX
1. What effect does free space on an index page have on its operations?
a. Affects the performance of index update operations.
2. Splitting index pages has a negative impact on performance if it happens too frequently..
How does this process occur?
a. Split Occurrence: A split occurs when {{226 - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -}}
b. New allocation: {{227 - - - - - - - - - - - - - - - - - - - -}}
c. Split: {{228 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
i. Meaning almost half of the index entries in the original page are moved to
the new page and marked.
3. How does FILLFACTOR option alleviate the impact of page splits?
a. It defines {{229 - - - - - - - - - -}}.
4. What types of indexes can it be used on?
a. {{230 - - - - - - - - - - - - - - -}}
5. Values of the FILLFACTOR option
a. 0: {{231 - - - - - - - - - - - - - - - - - - - - - -}}
b. Any other value: {{232 - - - - - - - - - - - - - - - - - -}}
c. Default: {{233}}
6. Difference between FILLFACTOR 0 and 100
a. FILLFACTOR 0 means {{234 - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
b. FILLFACTOR 100 means{{235 - - - - - - - - -}}
7. At what level of pages is a FILLFACTOR applied when PAD_INDEX = OFF
a. {{236 - - - - -}}
8. What does PAD_INDEX = ON mean?
a. {{237 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
9. In what scenarios is FILLFACTOR considered to impede performance?
a. FILLFACTOR does not have an impact if {{238 - - - - - - - - - - - - - - - - - - - -}}
i. Changes are on the last page anyway.
b. E.g. An index on a primary key column
10. Why is it important to weigh out the benefits and negative impacts of free space?
a. {{239 - - - - - - - - - - - - -}}, if the space adds no value.

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 - - - - - - - - - - - - - - - - - - - - - - - - -}}

Reorganizing and Index


{{269 - - - - - - - - - - - - - - - - - - - - - - - -}}

Working with Indexes Summarised


Why, when and how to rebuild and reorganize SQL Server indexes

Online Index Operations


1. What Editions of SQL Server can perform index operations online - while users are
accessing the database.
a. {{267 - -}}
2. What is the business case for performing index operations online?
a. Most organisations {{268 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
3. How does SQL Server keep track of changes taking place while performing online index
rebuild operation? - keep track of the changes occuring while the operation is running.
a. {{271 - - - - - - - - - - -}}
4. How does SQL Server ensure consistency when performing online index operations?
a. Locks: {{273 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}peration.
b. Database metadata: {{274 - - - - - - - - - - - - - - - - - - - - - - -}}
5. What does a schema lock mean for other database users?
a. {{275 - - - - - - - - - - - - - - - - - - -}}
i. Cannot change table structure.
6. What is the disadvantage of using online over offline index operations?
a. {{276 - - - - - - - - - - - - - -}}

Rebuilding an Index Online


1. {{277 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
Updating Statistics
1. One of the main tasks of the SQL Query Optimizer is to determine which indexes to use
and which ones not to use.
2. What does the Query Optimizer base its decisions on?
a. Statistics on {{278 - - - - - - - - -}}in the {{279 - - - - - - -}}
3. What does the AUTO_CREATE_STATISTICS setting do when turned on?
a. SQL Server automatically {{280 - - - - - - - - - - - - - - - - - - - - - - -}}
4. What is the general purpose of statistics?
a. To {{281 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
5. How to turn on AUTO_CREATE_STATISTICS?
a. {{282 - - - - - - - - - - - - - - - - - - - - - - -}}
6. What is the default setting for the AUTO_CREATE_STATISTICS option?
a. {{283 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
i. E.g. when using package solution that is on top of SQL Server layer.
7. What is the difference between synchronous AUTO_UPDATE_STATISTICS and
AUTO_UPDATE_STATISTICS_ASYNC when running a query?
a. Synchronous: {{284 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -}}
b. Asynchronous: {{285 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}
8. How can statistics be updated on demand?
a. Query: {{286 - - - - - - - - - - - -}}
b. Refreshes all statistics on the table.
9. What does the system stored procedure sp_updatestats() do?
a. {{287 - - - - - - - - - - - - - - - - - -}}
b. It checks which table has statistics that are out of date and refreshes them.

Lesson 3: Automating Routine Maintenance Tasks


Overview of SQL Server Maintenance Plans
1. What is the purpose of the SQL Server Maintenance Plan Wizard?
a. Create {{288 - - - - - - -}} that perform {{289 - - - - - - - - -}}.
2. At what point in the backup strategy should the integrity check be performed?
a. {{290}}, {{291 - - - - -}} or {{292}}.
3. How does the Wizard use SSIS packages?
a. The wizard creates packages for {{293 - - - - - - - - - - - - - - - - - - - - - - - - - - -}}.
4. What other features of the SQL Agent service are used by the wizard to facilitate the
monitoring and control of the tasks.
a. {{294}}
b. {{295 -}}
c. {{296 - - - - - -}}
d. Tables in the msdb database
e. Log File Viewer
5. What are the maintenance tasks involved?
a. {{297 - - - - - - - - - -}}
b. {{298 - - - - - -}}
c. {{299 - - - - - - - - - - - - - -}}
d. {{300 - - - - - - - - - - -}}
e. {{301 - - - - - - - - -}}
f. {{302 - - - - - - - - - - - - - - - - - - - - -}}

Monitoring Database Maintenance Plans


1. How does SQL Server implement maintenance plans?
a. Using {{303 - - - - - - -}} that run {{304 - - - -}}
2. What tool is used to monitor the running of the jobs?
a. {{305 - - - - - - -}}
3. Which database stores the results of the maintenance plans?
a. {{306}}
4. What tables in this database can be inspected to query the results?
a. {{307 - - - - -}}
b. {{308 - - - - - - - - - -}}
5. What is another alternative option provided by SQL Server to view the results of the
jobs?
a. Maintenance Plans logs {{309 - - - - - - - - - - - - - - - - - -}}
6. How do tasks combine with the file system and other tasks?
a. Task generate {{310 - - -}}
b. {{311 - - - - - - - - - - - - - - - - - - - -}}
c. {{312 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}}

You might also like