Professional Documents
Culture Documents
Tree Structured Indexing: Dr. Hari Om Gupta Professor, Department of Electrical Engineering IIT Roorkee
Tree Structured Indexing: Dr. Hari Om Gupta Professor, Department of Electrical Engineering IIT Roorkee
INDEXING
P0 K1 P1 K2 P2 … Km Pm
K1 K2 Kn Index file
Data file
Page 1 Page 2 Page 3 Page n+1
ISAM INDEX STRUCTURE
---
--- ---
--- -- ---
Data pages
Index pages
Overflow pages
1 3 5 64
8 3 1
10* 15* 20* 27* 33* 37* 42* 46* 51* 55* 64* 97*
1 3 5 64
8 3 1
Leaf pages
10* 15* 20* 27* 33* 37* 42* 46* 51* 55* 64* 97*
1 3 5 64
8 3 1
Leaf pages
10* 15* 20* 27* 42* 46* 51* 55* 64* 97*
Advantages
No need to lock index level pages thus queues & waiting
time to get access to a page is reduced in comparison to B+ tree.
It is static , response time will be less if overflow pages and
blank pages are few .
B+ TREE
(A DYNAMIC INDEX STRUCTURE)
K1 K2 Kn Index file
Data file
Page 1 Page 2 Page 3 Page n+1
One level index structure
Data entries
Page 1 Page 2 Page 3 Page n
A node other then root node may contain m entries such that
d<=m<=2d
2d is capacity of page (max. number of entries a page may store)
d is a parameter of the B+ tree called the order of the tree.
The leaf pages are chained together in a doubly linked list.
In the common case that alternative (2) or (3) is used as in ISAM.
However as general rule B+ tree are likely to perform better than ISAM.
Search
Insert
Root
14 17 24 30
1 3 5 7 15 16 19 20 23 24 26 29 33 34 39 41
5 1 2 3
3 4 0
1 3 5 7 8 15 16 19 20 23 2 26 29 33 34
4
1 3 5 7 8 15 16 19 20 23 24 26 29 33 34 39 41
For Redistribution
Have to retrieve the sibling with empty cell
Checking for redistribution increases I/O for index node spit.
Thus spit may not be advantageous.
For growing files
(a) Do not redistribute for non leaf vacancies
(b) Limited redistribution (Only with neighbours) for leaf pages
Delete
Search & delete with following restriction
If a node is at minimum occupancy before deletion and
deletion causes it to go below the occupancy threshold. When
this happens, we must either redistribute entries from an
adjacent sibling, or merge the node with a sibling, in order to
maintain minimum occupancy
Root 17
5 1 2 3
3 4 0
1 3 5 7 8 15 16 19 20 2 26 29 33 34
4
19 2 26 29 33 34 39 41 19 24 26 29 33 34 39 41
4
1 3 5 7 8 15 16 19 24 26 29 33 34 39 41
ISAM
Overflow pages
B+ Tree
Use (key, rid) the record entry no. along with key
may be used as search key
B+ Tree in Practice
1 5 6 8 9 10 12 14 15 16 20 22 31 35 39 41
Root
6 9 Sorted pages of data entries not yet in B+tree
1 5 6 8 9 10 12 14 15 16 20 22 31 35 39 41
9
Root
6 12 Sorted pages of data entries not yet in B+tree
1 5 6 8 9 10 12 14 15 16 20 22 31 35 39 41
1 5 6 8 9 10 12 14 15 16 20 22 31 35 39 41
Root
15
9 31
6 12 20 39
1 5 6 8 9 10 12 14 15 16 20 22 31 35 39 41
Complete B+ Tree
Multidimensional Indexes
Summary
Other variation of B tree >> not popular