















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















7– 1 Overview of Storage and Indexing ( 1. 1. 1 )
Oct 2017
✥ How does the DBMS storage data?
✥ Why is I/O is so important for database operations?
✥ Why are indices useful?
✥ A relation is typically stored as a file of records
✥ Rows are packed into records (pages)
✥ The simplest file structure is an unordered file or heap file ✦ Records are stored in random order ✦ The file manager is able to retrieve and store a particular record by its rid
✥ An index is a data structure that organizes data records to optimize certain kinds of retrieval operations ✦ They allow the efficient retrieval of records that satisfy a search condition on the search key ✦ Multiple indexes can be created on the same file (i.e table)
✥ A data entry is a record stored in an index file
✥ A data entry with search value k (denoted as k*) contains enough information to locate all records with search key value k
✥ There are 3 ways to store a data entry:
✥ If we want multiple indexes on a table, we will need to use 1 and 2 or 3.
✥ An index on the primary key is a primary index
✥ Other indexes are secondary indexes
✥ Two data entries are duplicates if the have same search key
✥ A primary index does not have duplicates
✥ A secondary index could have no duplicates if is specified as UNIQUE
✥ Indexes are usually implemented in one of two ways:
- -
Hash-based Indexing Tree-based Indexing
✥ The tree organizes the keys in order
Non-leaf Pages
Leaf Pages
✥ The inside nodes contain only keys, while the leafs contains the data entries
Root 17 Entries <= 17 Entries > 17 (^5 13 27 )
2* 3*
✥ B+ trees are the most commonly used ✦ They are guaranteed to be balanced ✦ The height of the tree is the length of a path from the root to the leaf (guaranteed to the always the same) ✦ Each node can have up to n children ( fan-out of the tree), so a tree of fan-out n has in the order of nh
5* 7* 8* 14* 16* 22* 24* 27* 29* (^) 33* 34* 38* 39*
For the sake of comparison we will use the following queries:
We will use a very simple cost model
✥ B is the number of data pages when pages are packed and there is no waste ✥ R is the number of records per page ✥ D is the avg. time to read or write a page ✥ C is the cost of comparing a key ✥ F is the fan out of the B+ trees ✥ H is the time to apply the hash function
D= ˜
15 ms, while C and H =˜
100ns, so we will concentrate on I/O
cost. We ignore other details (such as contiguity of pages)
✥ Scan : BD
✥ Search with Equality : BD
✥ Range Search : BD
✥ Insert : 2 D
✥ Delete : Search + D
2
7– 20 Overview of Storage and Indexing ( 1. 1. 1 ) CSC 370 [email protected]