2015-12-101 Index Tuning Conventional index. Overview.
-
Upload
tobias-newton -
Category
Documents
-
view
212 -
download
0
Transcript of 2015-12-101 Index Tuning Conventional index. Overview.
23/4/21 1
Index Tuning
Conventional index
Overview
23/4/21 3
Duplicate keys
1010
2010
3020
3030
4540
23/4/21 4
1010
2010
3020
3030
4540
10101020
20303030
1010
2010
3020
3030
4540
10101020
20303030
Dense index, one way to implement?
• Query– Look for
the first K, then search forward
Duplicate keys
23/4/21 5
1010
2010
3020
3030
4540
10203040
Dense index, better way?
Duplicate keys
• Each pointer points to the first of records with key K
• Query– Find the
first occurrence, then move forward
23/4/21 6
1010
2010
3020
3030
4540
10102030
Sparse index, one way?
Duplicate keysca
refu
l if lookin
gfo
r 2
0 o
r 3
0!
• Find the last index entry with key <=K
• Then, search backward until coming to the first entry or meeting an index entry E2
with key strictly less than k
23/4/21 7
1010
2010
3020
3030
4540
10203030
Sparse index, another way?
Duplicate keys
– place first new key from block
23/4/21 8
Duplicate values, primary index
• Index may point to first instance ofeach value only
File
Index
Summary
aaa
b
23/4/21 9
Deletion from sparse index
2010
4030
6050
8070
10305070
90110130150
23/4/21 10
Deletion from sparse index
2010
4030
6050
8070
10305070
90110130150
– delete record 40
23/4/21 11
Deletion from sparse index
2010
4030
6050
8070
10305070
90110130150
– delete record 30
4040
23/4/21 12
Deletion from sparse index
2010
4030
6050
8070
10305070
90110130150
– delete records 30 & 40
5070
23/4/21 13
Deletion from dense index
2010
4030
6050
8070
10203040
50607080
23/4/21 14
Deletion from dense index
2010
4030
6050
8070
10203040
50607080
– delete record 30
4040
23/4/21 15
Insertion, sparse index case
2010
30
5040
60
10304060
23/4/21 16
Insertion, sparse index case
2010
30
5040
60
10304060
– insert record 34
34
• our lucky day! we have free space where we need it!
23/4/21 17
Insertion, sparse index case
2010
30
5040
60
10304060
– insert record 15
15
2030
20
• Illustrated: Immediate reorganization
•In principle, we may have had to slide every record to the end of the file
• Variation:– insert new block (chained file)– update index
23/4/21 18
Insertion, sparse index case
2010
30
5040
60
10304060
– insert record 25
25
overflow blocks(reorganize later...)
• No index entry for overflow blocks, which is considered as an extension of data block
23/4/21 19
Insertion, dense index case
• Similar
• Often more expensive . . .
summary