Index Tuning Conventional index 2017/7/31 1 Overview Duplicate keys 10 10 10 20 20 30 30 30 40 45 2017/7/31 3 Duplicate keys Dense index, one way to implement? • Query 10 10 – Look for 10 the first K, 20 then search forward 20 30 30 30 10 10 10 20 20 30 30 30 40 45 2017/7/31 4 Duplicate keys Dense index, better way? • Each pointer points to the first of records with key K • Query – Find the first occurrence, then move forward 2017/7/31 10 20 30 40 10 10 10 20 20 30 30 30 40 45 5 Duplicate keys careful if looking for 20 or 30! Sparse index, one way? 10 10 10 20 30 10 10 20 20 30 30 30 40 45 2017/7/31 • 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 6 Duplicate keys Sparse index, another way? – place first new key from block 10 20 30 30 10 10 10 20 20 30 30 30 40 45 2017/7/31 7 Summary Duplicate values, primary index • Index may point to first instance of each value only File Index a a a . . b 2017/7/31 8 Deletion from sparse index 10 30 50 70 90 110 130 150 2017/7/31 10 20 30 40 50 60 70 80 9 Deletion from sparse index – delete record 40 10 30 50 70 90 110 130 150 2017/7/31 10 20 30 40 50 60 70 80 10 Deletion from sparse index – delete record 30 10 40 30 50 70 90 110 130 150 2017/7/31 10 20 30 40 40 50 60 70 80 11 Deletion from sparse index – delete records 30 & 40 10 50 30 70 50 70 90 110 130 150 2017/7/31 10 20 30 40 50 60 70 80 12 Deletion from dense index 10 20 30 40 50 60 70 80 2017/7/31 10 20 30 40 50 60 70 80 13 Deletion from dense index – delete record 30 10 20 40 30 40 50 60 70 80 2017/7/31 10 20 30 40 40 50 60 70 80 14 Insertion, sparse index case 10 30 40 60 10 20 30 40 50 60 2017/7/31 15 Insertion, sparse index case – insert record 34 10 30 40 60 10 20 30 34 40 50 • our lucky day! we have free space 60 where we need it! 2017/7/31 16 Insertion, sparse index case – insert record 15 10 20 30 40 60 10 20 15 30 20 30 40 • Illustrated: Immediate reorganization •In principle, we may have had to slide every record to the end of the file • Variation: 50 60 – insert new block (chained file) – update index 2017/7/31 17 Insertion, sparse index case – insert record 25 10 30 40 60 10 25 20 30 overflow blocks (reorganize later...) 40 50 60 2017/7/31 • No index entry for overflow blocks, which is considered as an extension of data block 18 Insertion, dense index case • Similar • Often more expensive . . . 2017/7/31 19 summary
© Copyright 2026 Paperzz