index3(1)
index3(1)
Single-level Indexes
Primary Indexes
Clustering Indexes
Secondary Indexes
Hash-Based Index
Multi-level Indexes / Tree-Based Index
1
Hashed-Based Indexing
6
Example
7
Example
What kind of index to build on this key field? Primary index
If index bfr = 4, how many index blocks? 4 blocks
To find a record: Binary search the 4 index blocks
Can we do better?
8
Create an index on the index!
9
Multi-Level Indexes
Because a single-level index is an ordered
file: create a primary index to the index itself!
original index file is called first-level index
(base)
10
Multi-level Index
11
Multi-level Indexing Cont.
Data Blocks
13
Multi-level Indexing
2nd level
128 107 85 55 35 2
Data Blocks
15
Multi-level Indexing Cont.
128 107 85 55 35 2
18
Multi-level Index: Example
Search for 140
Number of accessed blocks:
3 index blocks
+ 1 data block
= 4 blocks in total
107 2
128 107 85 55 35 2
20
Index File vs. Data File!
Data file
Index file
21
Index File vs. Data File!
Data file
Index file
22
Multi-level index as a tree
Multi-level index is a form of search tree
Each node has pointers
By following a pointer, we restrict our search to a
subtree and ignore all other nodes
The number of pointers (fan-out ) is the index blocking
factor which is the number of children a node has
23
Dynamic Data