B+-Trees: Adapted From Mike Franklin
B+-Trees: Adapted From Mike Franklin
Root
40
20
33
51
63
10*
15*
20*
27*
33*
37*
40*
46*
51*
55*
63*
97*
ISAM
Indexed Sequential Access Method Similar to what we discussed in the last class
Root Index Pages
40
20
33
51
63
63*
97*
Overflow
Pages
23*
48*
41*
42*
Example B+ Tree
Search begins at root, and key comparisons direct it to a leaf. Search for 5*, 15*, all data entries >= 24* ...
Root
13 17 24 30
2*
3*
5*
7*
14* 16*
B+ Tree - Properties
Balanced Every node except root must be at least full. Order: the minimum number of keys/pointers in a non-leaf node Fanout of a node: the number of pointers out of the node
B+ Trees in Practice
Typical order: 100. Typical fill-factor: 67%.
average fanout = 133
Typical capacities:
Height 3: 1333 = 2,352,637 entries Height 4: 1334 = 312,900,700 entries
B+ Trees: Summary
Searching:
logd(n) Where d is the order, and n is the number of entries
Insertion:
Find the leaf to insert into If full, split the node, and adjust index accordingly Similar cost as searching
Deletion
Find the leaf node Delete May not remain half-full; must adjust the index accordingly
Insert 23*
Root
13 17 24 30
2*
3*
5*
7*
14* 16*
No splitting required.
Root
13 17 24
30
2*
3*
5*
7*
14* 16*
13
24
30
2* 2*
3* 3*
5*
7*
5*
14* 16* 7* 8*
14* 16*
24* 27* 29* 19* 20* 22* 19* 20* 22* 24* 27* 29*
Notice that root was split, leading to increase in height. In this example, we can avoid split by re-distributing entries; however, this is usually not done in practice.
Entry to be inserted in parent node. (Note that 5 is copied up and s continues to appear in the leaf.)
2*
3*
5*
7*
8*
13 17
24
30
17
Entry to be inserted in parent node. (Note that 17 is pushed up and only appears once in the index. Contrast this with a leaf split.)
13
24
30
Delete 19*
Root
17
Root
5 13 13 2* 3* 5* 7* 8* 17 24 30 33* 34* 38* 39* 24 30
14* 16*
2*
3*
5*
7*
14* 16*
Root
17
13
24
30
2*
3*
5*
7* 8*
14* 16*
20* 22*
13
24
30
2*
3*
5*
7* 8*
14* 16*
20* 22*
Root
17
13
27
30
2*
3*
5*
7* 8*
14* 16*
22* 24*
27* 29*
13
27
30
2*
3*
5*
7* 8*
14* 16*
22* 24*
27* 29*
Root
17
13
27
30
2*
3*
5*
7* 8*
14* 16*
22*
27* 29*
Deleting 24*
Must merge. Observe `toss of index entry (on right), and `pull down of index entry (below).
22* 27* 29* 30
33*
34*
38*
39*
Root
5 13
17
30
2*
3*
5*
7*
8*
14* 16*
13
17
20
30
2* 3*
5* 7* 8*
14* 16*
17* 18*
20* 21*
After Re-distribution
Intuitively, entries are re-distributed by `pushing through the splitting entry in the parent node. It suffices to re-distribute index entry with key 20; weve redistributed 17 as well for illustration.
Root
17
13
20
22
30
2* 3*
5* 7* 8*
14* 16*
17* 18*
20* 21*
Secondary index:
Built on an attribute that the file is not sorted on.
13
20
22
30
14 16
17 18
20 21
22 27 29
33 34 38 39
2* 16* 5* 39*
Secondary index:
Built on an attribute that the file is not sorted on.
More
Hash-based Indexes
Static Hashing Extendible Hashing
Read on your own.
Linear Hashing