Professional Documents
Culture Documents
Computing Systems
Operators for Data Access
(contd.)
Shivnath Babu
Insertion in a B-Tree
n=2
49
15 36
49
Insert: 62
Insertion in a B-Tree
n=2
49
15 36
49
62
Insert: 62
Insertion in a B-Tree
n=2
49
15 36
49
62
Insert: 50
Insertion in a B-Tree
49
15 36
n=2
62
49
50
62
Insert: 50
Insertion in a B-Tree
49
15 36
n=2
62
49
50
62
Insert: 75
Insertion in a B-Tree
49
15 36
n=2
62
49
50
62 75
Insert: 75
Insertion
Insertion
Insertion
10
Insertion
11
Insertion
12
Insertion
13
Insertion
14
Insertion
15
Insertion
16
Insertion
17
Insertion
18
Insertion: Primitives
19
58
54 57 60 62
20
58
54 57
60 62
21
58
54 57 58 60 62
22
54 66
54 57 58 60 62
23
54 66
54 57 58 60 62
24
54 66
54 57 58
60 61 62
25
54 66
54 57 58
60 61 62
26
54 59 66
54 57 58
60 61 62
27
21 99
59
40 54 66 74 84
21 99
59
40 54 66 74 84
21 99
[21,66)
40 54 59
[54, 59)
[66, 99)
74 84
[ 59, 66)
[66,74)
59
40 54 66 74 84
59
40 54 66 74 84
40 54 59
[54, 59)
74 84
[ 59, 66)
[66,74)
Deletion
34
Deletion
redistribute
35
Deletion
36
Deletion - II
37
Deletion - II
merge
Deletion - II
39
Deletion - II
40
Deletion - II
41
Deletion - II
Not needed
merge
42
Deletion - II
43
Deletion: Primitives
54 58 64
67 85
68 72 75
45
54 58 64
67 85
68 75
46
67 85
54 58 64 68 75
47
85
54 58 64 68 75
48
41 48 52
59
63 74
[52, 59)
[59,63)
49
59
41 48 52 59 63
[52, 59)
[59,63)
50
B-Tree Roadmap
B-Tree
Recap
Insertion (recap)
Deletion
Construction
Efficiency
B-Tree variants
Hash-based Indexes
51
Question
52
B-Tree Construction
Sort
48 57 41 15 75 21 62 34 81 11 97 13
53
B-Tree Construction
11 13 15
21 34 41
48 57 62
75 81 97
11 13 15 21 34 41 48 57 62 75 81 97
Scan
B-Tree Construction
21 48 75
11 13 15
21 34 41
Scan
48 57 62
75 81 97
B-Tree Construction
56
Cost of B-Tree
Operations
Height of B-Tree: H
Assume no duplicates
Question: what is the random I/O
cost of:
Insertion:
Deletion:
Equality search:
Range Search:
57
Height of B-Tree
Number of keys: N
B-Tree parameter: n
log N
Height log
N =
n
log n
In practice: 2-3 levels
58
59
Roadmap
B-Tree
B-Tree variants
Sparse Index
Duplicate Keys
Hash-based Indexes
60
Roadmap
B-Tree
B-Tree variants
Hash-based Indexes
Static Hash Table
Extensible Hash Table
Linear Hash Table
61
Hash-Based Indexes
62
record pointer
a1
a2
A = val
ai
an
key
h (key)
0
1
32
48
10
(null)
27
75
3
4
h (key) = key % 8 5
21
6
7
55
(null)
(null)
(null)
(null)
64
Adapting to disk
65
Adapting to Disk
Adapting to disk
67
Adapting to Disk
68
Adapting to disk
69
70