Topic 2: Indexing and Sorting Chapters 10, 11, and 13 of Cow Book
Arun Kumar
1
CSE 232A Graduate Database Systems Arun Kumar Topic 2: Indexing - - PowerPoint PPT Presentation
CSE 232A Graduate Database Systems Arun Kumar Topic 2: Indexing and Sorting Chapters 10, 11, and 13 of Cow Book Slide ACKs: Jignesh Patel, Paris Koutris 1 Motivation for Indexing Consider the following SQL query: Movies (M)
1
2
3
4
5
6
7
8
h 1 N-1
9
10
11
12
13
17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13
14
R1 K 1 R 2 K2 K n P n+1
record 1 record 2 Next Page Pointer
Rn
record n
P0
Prev Page Pointer
P1 K 1 P2 K 2 P3 K m P m+1
Pointer to a page with Values < K1 Pointer to a page with values s.t. K1≤ Values < K2 Pointer to a page with values ≥Km Pointer to a page with values s.t., K2≤ Values < K3
Pm
15
16
17
17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13
2* 3* 5* 7* 8*
18
5 24 30 17 13
19
2* 3*
17 24 30 14*16* 19*20*22* 24* 27*29* 33*34*38*39* 13 5 7* 5* 8*
20
17 24 30 2* 3* 5* 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 13 8* 14* 16* 8
21
22
27*29* 2* 3* Root 17 24 30 14*16* 19* 20*22* 24* 33*34*38*39* 13 5 7* 5* 8* 27 24* 27* 29*
23
30 19* 27* 29* 33* 34* 38* 39*
2* 3* 7* 14* 16* 19* 27* 29* 33* 34* 38* 39* 5* 8*
30 13 5 17
24
13 5 17 20 22 30 14* 16* 17*18* 20* 33*34*38* 39* 22* 27*29* 21* 7* 5* 8* 3* 2*
25
14*16* 33* 34*38* 39* 22* 27*29* 17*18* 20* 21* 7* 5* 8* 2* 3*
13 5 17 30 20 22
26
27
28
29
30
31
14 5 14*16* 17*18* 20* 22* 27* 21* 7* 5* 3* 2*
14 17 20
32
33
34
h 1 N-1
2
35
(15, Avatar, …) (52, Gravity, …) (20, Inception, …) (74, Blue …)
36
37
38
2 2 4* 12* 32* 16* 2 1* 13* 41* 17* 2 10* 2 7* 15*
39
40
2 2 4* 12* 32* 16* 2 1* 13* 41* 17* 2 10* 2 7* 15*
3 32* 16* 24* 3 4* 12*
41
3 3 32* 16* 24* 2 1* 13* 41* 17* 2 10* 2 7* 15*
3 4* 12*
18*
3 13*
3 1* 41* 17*
42
43
2 2 4* 12* 2 1* 13* 41* 17* 2 26* 2 7* 15*
1
44
45
46
47
48
49
50
51
52
53
Input file 3,4 6,2 9,4 8,7 5,6 3,1 2 1-page runs PASS 0 3,4 5,6 2,6 4,9 7,8 1,3 2 2-page runs PASS 1 2,3 4,6 4,7 8,9 1,3 5,6 2 4-page runs PASS 2 2,3 4,4 6,7 8,9 1,2 3,5 6 8-page runs PASS 3 9 1,2 2,3 3,4 4,5 6,6 7,8
54
55
56
57
INPUT 1 INPUT B-1 OUTPUT
INPUT 2
58
59
60
61
62
63
64
65
66
67
68