1 340151 Big Databases & Cloud Services (P. Baumann)
Indexing
Ramakrishnan/Gehrke Ch. 8
“How index-learning turns no student pale Yet holds the eel of science by the tail.”
- - Alexander Pope (1688-1744)
Indexing Ramakrishnan/Gehrke Ch. 8 How index -learning turns no - - PowerPoint PPT Presentation
Indexing Ramakrishnan/Gehrke Ch. 8 How index -learning turns no student pale Yet holds the eel of science by the tail. -- Alexander Pope (1688-1744) 340151 Big Databases & Cloud Services (P. Baumann) 1 Range Searches `` Find
1 340151 Big Databases & Cloud Services (P. Baumann)
Ramakrishnan/Gehrke Ch. 8
“How index-learning turns no student pale Yet holds the eel of science by the tail.”
2 340151 Big Databases & Cloud Services (P. Baumann)
binary search to find first student, then scan to find rest
tuple 1 tuple 2 tuple N tuple 3
Data File
k2 kN k1
Index File
3 340151 Big Databases & Cloud Services (P. Baumann)
4 340151 Big Databases & Cloud Services (P. Baumann)
Index pages Leaf pages
fill factor
P0 K1 P1 K2 P2 Km Pm
5 340151 Big Databases & Cloud Services (P. Baumann)
m-1 keys.
m/2 children.
[http://btechsmartclass.com/data_structures/b-trees.html]
6 340151 Big Databases & Cloud Services (P. Baumann)
2* 3*
Root
17
30 14* 16* 33* 34* 38* 39* 13 5 7* 5* 8* 22* 24* 27 27* 29*
Note how data entries in leaf level are sorted
https://www.cs.usfca.edu/~galles/visualization/BTree.html
7 340151 Big Databases & Cloud Services (P. Baumann)
[https://condor.depaul.edu/ntomuro/courses/417/notes/lecture3.html]
8 340151 Big Databases & Cloud Services (P. Baumann)
9 340151 Big Databases & Cloud Services (P. Baumann)
[Shankai Yan]
10 340151 Big Databases & Cloud Services (P. Baumann)
11 340151 Big Databases & Cloud Services (P. Baumann)
Data Records Index entries direct search for data entries Data entries
CLUSTERED UNCLUSTERED
Data file Data Records Index File
12 340151 Big Databases & Cloud Services (P. Baumann)
Every field value equal to a constant value Ex: for <sal,age> index: age=20 and sal=75
Some field value within interval Ex: age>20; or age=20 and sal>10
<age, sal> 12,20 12,10 11,80 20,75 <age> 11 12 12 20
Data records sorted by name
20 75 12 10 20 80 11 12 name age sal sue bob cal joe <sal, age> 20,12 10,12 75,20 80,11
Data entries in index sorted by <sal,age>
<sal> 10 20 75 80
Data entries sorted by <sal>
Examples of composite key indexes using lexicographic order:
13 340151 Big Databases & Cloud Services (P. Baumann)
than <sal,age> index!
14 340151 Big Databases & Cloud Services (P. Baumann)
SELECT E.dno, COUNT(*) FROM Emp E GROUP BY E.dno
SELECT E.dno, MIN(E.sal) FROM Emp E GROUP BY E.dno
SELECT AVG(E.sal) FROM Emp E WHERE E.age=25 AND
15 340151 Big Databases & Cloud Services (P. Baumann)
SELECT E.dno, COUNT (*) FROM Emp E WHERE E.age=30 GROUP BY E.dno
16 340151 Big Databases & Cloud Services (P. Baumann)
SELECT E.dno, COUNT (*) FROM Emp E WHERE E.age=30 GROUP BY E.dno SELECT E.dno, COUNT (*) FROM Emp E WHERE E.age>30 GROUP BY E.dno
17 340151 Big Databases & Cloud Services (P. Baumann)
SELECT D.dno FROM Dept D, Emp E WHERE D.dno=E.dno
SELECT D.dno, E.eid FROM Dept D, Emp E WHERE D.dno=E.dno
18 340151 Big Databases & Cloud Services (P. Baumann)
19 340151 Big Databases & Cloud Services (P. Baumann)
hash index
tree index
20 340151 Big Databases & Cloud Services (P. Baumann)
choose based on important queries that benefit most from clustering
21 340151 Big Databases & Cloud Services (P. Baumann)
search
22 340151 Big Databases & Cloud Services (P. Baumann)
23 340151 Big Databases & Cloud Services (P. Baumann)