Indexing File Management
Indexing used to speed up retrieval of records.
It was done with the help of a separate sequential file. Each record of in the index file consists of two fields, a key field, and a pointer into the main file.
Moreover, To find a specific record for the given key value, the index searched for the given key value.
Also, Binary search can use to search in an index file. After getting the address of record from the index file, the record in the main file can easily retrieve.
- The index file ordered on the ordering key Roll No. each record of index file points to the corresponding record. Also, The main file not sorted.
Advantages of indexing over sequential file
- A sequential file can search effectively by ordering key. Moreover, When it is necessary to search for a record on the basis of some other attribute than the ordering key field, sequential file representation is inadequate.
- Multiple indexes can be maintained for each type of field used for searching. Thus, indexing provides much better flexibility.
- An index file usually requires less storage space than the main file. Also, A binary search on sequential file will require accessing of more blocks. This can explain with the help of the following example. Also, Consider the example of a sequential file with r = 1024 records of fixed length with record size R = 128 bytes stored on disk with block size B = 2048 bytes.
- Moreover, Number of blocks required to store the file
- Number of block accesses for searching a record = log264= 6
- Suppose, we want to construct an index on a key field that is V = 4 bytes long and the block pointer is P = 4 bytes long.
- A record of an index file of the form <V, Pj> and it will need 8 bytes per entry.
- Also, Total Number of index entries = 1024
- Number of blocks b’ required to store the file
- Moreover, Number of blocks accesses for searching a record = log24= 2
- With indexing, new records can add at the end of the main file. Also, It will not require movement of records as in the case of the sequential file. Updation of index file requires fewer block accesses compare to sequential file.