093.indexes Part3
093.indexes Part3
Indexes
Follow us on :
Page
In SQL Server, the fundamental unit of data storage is the page.
All disk I/O operations occur at the page level, meaning SQL
Server reads and writes entire pages at a time.
Follow us on :
Extent
Follow us on :
Extent
Instead, it utilizes two types of extents:
Follow us on :
Table Organization
A table consists of one or more
partitions, with each partition
storing data rows in either a heap
or a clustered index structure.
Follow us on :
Database Files
SQL Server databases have three types of files:
Follow us on :
Database Files
2. Secondary data files
Secondary data files make up all the data files, other than the
primary data file. Some databases may not have any secondary data
files, while others have several secondary data files. The
recommended file name extension for secondary data files is .ndf.
3. Log files
Log files hold all the log information that is used to recover the
database. There must be at least one log file for each database,
although there can be more than one. The recommended file name
extension for log files is .ldf.
Follow us on :
Database Files
Follow us on :
Index Allocation Mapping (IAM)
Index Allocation Mapping (IAM) is a system table structure
in SQL Server that tracks which extents belong to a
specific table or index.
Follow us on :
Heap Structures
A heap is a table without a clustered index.
Follow us on :
Heap Structures
A RID (Row Identifier) Lookup occurs when SQL Server retrieves
data from a heap (a table without a clustered index) using a Non-
Clustered Index but needs additional columns that are not included
in the index.
If the query requests columns not present in the index, SQL Server
must go back to the heap to fetch the missing data.
3. RID Lookup happens to fetch the missing columns from the heap.
Follow us on :
Clustered Table Organization
Clustered tables are tables that have a clustered index.
Follow us on :
Clustered Index structures
In SQL Server, indexes are organized as
B-trees.
Each page in an index B-tree is called
an index node.
The top node of the B-tree is called the
root node.
The bottom level of nodes in the index
is called the leaf nodes. Any index
levels between the root and the leaf
nodes are collectively known as
intermediate levels.
Follow us on :
Clustered Index structures
In a clustered index, the leaf nodes contain the data pages of the
underlying table.
The root and intermediate level nodes contain index pages
holding index rows.
Each index row contains a key value and a pointer to either an
intermediate level page in the B-tree, or a data row in the leaf
level of the index. The pages in each level of the index are linked
in a doubly-linked list.
Follow us on :
Non-Clustered Index structures
Nonclustered indexes have the same
B-tree structure as clustered indexes,
except for the following significant
differences:
1. The data rows of the underlying table
are not sorted and stored in order
based on their nonclustered keys.
2. The leaf layer of a nonclustered index
is made up of index pages instead of
data pages.
Follow us on :
Non-Clustered Index structures
Nonclustered indexes can be defined on a table or view
with a clustered index or a heap.
Follow us on :
Non-Clustered Index structures