Sparse Index Files Sparse Index:contains index records for only some search-key values. Applicable when records are sequentially ordered on search-key To locate a record with search-key value K we: Find index record with largest search-key value K Search file sequentially starting at the record to which the index record points Brighton A-217 Brighton 750 Mianus A-101 Downtown 500 Redwood A-110 Downtown 600 A-215 Mianus 700 A-102 Perryridge 400 A-201 Perryridge 900 A-218 Perryridge 700 A-222 Redwood 700 A-305 Round Hill 350 Database System Concepts-5th Edition,Oct 4,2006 12.7 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 12.7 ©Silberschatz, Korth and Sudarshan th Edition, Oct 4, 2006 Sparse Index Files Sparse Index: contains index records for only some search-key values. Applicable when records are sequentially ordered on search-key To locate a record with search-key value K we: Find index record with largest search-key value < K Search file sequentially starting at the record to which the index record points
Sparse Index Files (Cont.) Compared to dense indices: Less space and less maintenance overhead for insertions and deletions. Generally slower than dense index for locating records. Good tradeoff:sparse index with an index entry for every block in file, corresponding to least search-key value in the block. data block 0 data block 1 Database System Concepts-5th Edition,Oct 4,2006 12.8 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 12.8 ©Silberschatz, Korth and Sudarshan th Edition, Oct 4, 2006 Sparse Index Files (Cont.) Compared to dense indices: Less space and less maintenance overhead for insertions and deletions. Generally slower than dense index for locating records. Good tradeoff: sparse index with an index entry for every block in file, corresponding to least search-key value in the block
Multilevel Index If primary index does not fit in memory,access becomes expensive Solution:treat primary index kept on disk as a sequential file and construct a sparse index on it. outer index-a sparse index of primary index inner index-the primary index file If even outer index is too large to fit in main memory,yet another level of index can be created,and so on. Indices at all levels must be updated on insertion or deletion from the file. Database System Concepts-5th Edition,Oct 4,2006 12.9 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 12.9 ©Silberschatz, Korth and Sudarshan th Edition, Oct 4, 2006 Multilevel Index If primary index does not fit in memory, access becomes expensive. Solution: treat primary index kept on disk as a sequential file and construct a sparse index on it. outer index – a sparse index of primary index inner index – the primary index file If even outer index is too large to fit in main memory, yet another level of index can be created, and so on. Indices at all levels must be updated on insertion or deletion from the file
Multilevel Index (Cont.) index data block 0 block 0 index data block 1 block 1 outer index inner index Database System Concepts-5th Edition,Oct 4,2006 12.10 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 12.10 ©Silberschatz, Korth and Sudarshan th Edition, Oct 4, 2006 Multilevel Index (Cont.)
Index Update:Deletion If deleted record was the only record in the file with its particular search- key value,the search-key is deleted from the index also. Single-level index deletion: Dense indices-deletion of search-key:similar to file record deletion Sparse indices- if an entry for the search key exists in the index,it is deleted by replacing the entry in the index with the next search-key value in the file (in search-key order). If the next search-key value already has an index entry,the entry is deleted instead of being replaced. Brighton A-217 Brighton 750 Mianus A-101 Downtown 500 Redwood A-110 Downtown 600 A-215 Mianus 700 A-102 Perryridge 400 A-201 Perryridge 900 A-218 Perryridge 700 A-222 Redwood 700 A-305 Round Hill 350 Database System Concepts-5th Edition,Oct 4,2006 12.11 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 12.11 ©Silberschatz, Korth and Sudarshan th Edition, Oct 4, 2006 Index Update: Deletion If deleted record was the only record in the file with its particular searchkey value, the search-key is deleted from the index also. Single-level index deletion: Dense indices – deletion of search-key:similar to file record deletion. Sparse indices – if an entry for the search key exists in the index, it is deleted by replacing the entry in the index with the next search-key value in the file (in search-key order). If the next search-key value already has an index entry, the entry is deleted instead of being replaced