Presentation is loading. Please wait.

Presentation is loading. Please wait.

INDEXING.

Similar presentations


Presentation on theme: "INDEXING."— Presentation transcript:

1 INDEXING

2 Basic concepts An index on a file is an auxiliary structure designed to speed up operations to locate records in the file. An index can be viewed as a collection of data entries, with an efficient way to locate all data entries with search key value k. There are 2 basic kinds of indices Ordered indices – Based on a stored ordering of the values Hash indices – Based on a uniform distribution of values across a range of buckets.

3

4 Types of Index Ordered indexes Clustering index Secondary index
Primary index Dense and sparse indices Clustering index Secondary index Multilevel indexes

5 Ordered Indices

6 Ordered Indices cont… Primary index
It is an index on the ordering key field of the ordered file. Every record has a unique value for this key field. It is ordered file with 2 fields and record length is fixed. One field has the same data type and length as the key field (this is also called the primary key). The field has the key value of the first record in the block. The second field has the address of the block where the record (data) resides, corresponding to the key value. Number of the entries in the index is equal to the number of data blocks.

7 Dense and sparse indices
There are two types of ordered indices that we can use Dense index – It has an index for every search key value in the data file. Sparse index (non dense) – It has index entries for only some of the search values.

8

9 Clustering index Records can be physically ordered on a non key field, which does have a distinct (unique) value for each clustering field. This field is called clustering index. An index on a clustering field is called clustering index. It is also an ordered file with two fields. 1st Field  Similar to clustering field of the data file. 2nd Field Contains a pointer to the first block in the data file with this key value. It is a non-dense (spares) index.

10 Secondary index

11 Secondary index cont.. An index on any non-ordering field of a file is called a secondary index. A file can have any number of secondary indexes. (There can be only one primary index). It is also an ordered file with two fields. The first field is same data as the non-ordering field of the file on which the index is to be created. The second field is either a block pointer or record pointer. The number of entries in a secondary index is more than the number of entries in a primary index. The secondary index can be On a non ordering index field which has unique values in the field (no duplicates on this field). This result in a dense index that is each record will have a corresponding entry in the index file.

12 Multilevel indexes 

13 Multilevel indexes  The purpose of multilevel indexing is to reduce the number of block access required to locate a record. More than on level of index files are maintained. Every level will reduce the number of block access required by a factor of bfr(blocking factor). This is called fan out of the multilevel index. The first level is an ordered file with a distinct value for each K(i). The second level is primary index for the first level has one entry for block of the first level. The third level is the primary index for the second level has an entry for some index level fit in a single block. This is called the top index level.


Download ppt "INDEXING."

Similar presentations


Ads by Google