Understanding database [4] : Indexes

Understanding database 4 : Indexes

As we have covered with little mentioning in the previous posts, indexes are crucial for the upgrade for performance of databases. There are 3 main types of indexes, including Tree-based indexes (ISAM, B+ tree), Hash based indexes (Extendible hashing, linear hashing) and bitmap indexes.

By definition, we consider index as a ‘a set of pages with pointers to the data page which contains the value’, namely we use a separate file for the ease of efficient accessing to various files. This upgrades the efficiency as we do not have to scan the entire relation (built up by tables etc) every time, but we will only have to look up the indexes which is much less data to search through. We may consider the use of index is more efficient if
(index lookup cost + record retrieval cost) < file scan cost
and we will make indexing decisions based on this relation.

We create an index in SQL with the format
CREATE INDEX ON <Table> (<attributes1>...)
and this allows us to create a customized index of our wanted attributes from one table that we would like to manipulate.

Typically, each index entry for a data record is a row, where each entry contains a search key value and pointer to a record in the table. The retrieval of records are based on the corresponding search key value, and the pointer references to the actual data record in the database.

Although we could grant a rather efficient look up performance for sorted files, it is still rather expensive for large data to update or to make access after all. As a solution, we introduce sparse indexes for the data file, and we give each page’s first entry a sparse index in order to allow for a further improved binary search. With the idea being recursively applied, we may able to generate Tree based indexes where we have non leaf levels that has its entries as pointers to index pages, and leaves as entries pointing to actual records. This is how we construct the tree based indexes that we have mentioned in the first paragraph. 

Comments

Popular Posts