Index Tuning Conventional index
Overview
Duplicate keys
Dense index, one way to implement? Query –Look for the first K, then search forward Duplicate keys
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
Sparse index, one way? Duplicate keys careful if looking for 20 or 30! Find the last index entry with key <=K Then, search backward until coming to the first entry or meeting an index entry E 2 with key strictly less than k
Sparse index, another way? Duplicate keys – place first new key from block
Duplicate values, primary index Index may point to first instance of each value only File Index Summary a a a b
Deletion from sparse index
Deletion from sparse index – delete record 40
Deletion from sparse index – delete record 30 40
Deletion from sparse index – delete records 30 &
Deletion from dense index
Deletion from dense index – delete record 30 40
Insertion, sparse index case
Insertion, sparse index case – insert record our lucky day! we have free space where we need it!
Insertion, sparse index case – insert record 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
Insertion, sparse index case – insert record overflow blocks (reorganize later...) No index entry for overflow blocks, which is considered as an extension of data block
Insertion, dense index case Similar Often more expensive...
summary