What is Primary Indexing?

A Primary Index is an ordered file whose records are of fixed length with two fields. The first field of the index is the primary key of the data file in an ordered manner, and the second field of the ordered file contains a block pointer that points to the data block where a record containing the key is available.

Primary Indexing

Primary Indexing in Databases

Indexing is a technique used to reduce access cost or I/O cost, now the question arrives what is access cost? Access cost is defined as the number of secondary memory blocks which is transferred from secondary memory to main memory in order to access required data. In this article, we are going to discuss every point about primary indexing.

Similar Reads

What is Primary Indexing?

A Primary Index is an ordered file whose records are of fixed length with two fields. The first field of the index is the primary key of the data file in an ordered manner, and the second field of the ordered file contains a block pointer that points to the data block where a record containing the key is available....

Working of Primary Indexing

In primary indexing, the data file is sorted or clustered based on the primary key as shown in the below figure. An index file (also known as the index table) is created alongside the data file. The index file contains pairs of primary key values and pointers to the corresponding data records. Each entry in the index file corresponds to a block or page in the data file....

Types of Primary Indexing

Dense Indexing: In Dense Index has an index entry for every search key value in the data file. This approach ensures efficient data retrieval but requires more storage space. No of Index Entry = No of DB Record...

Advantages of Primary Indexing

Primary indexing allowed fast retrieval of records based on their primary key values. Primary indexing reduces the need for full-table scans or sequential lookups, due to which it reduce disk I/O operations. The data file is organized based on the primary key, ensuring that records are stored in a logical order. This organization simplifies range queries and other operations. Each block in the data file corresponds to an entry in the primary index. Therefore, the average number of blocks accessed using the primary index can be estimated as approximately log₂(B + 1), where B represents the number of index blocks....

Disadvantages of Primary Indexing

Primary indexing requires additional space to store the index field alongside the actual data records. This extra storage can impact overall system costs, especially for large datasets. When records are added or deleted, the data file needs reorganization to maintain the order based on the primary key. After record deletion, the space used by the deleted record must be released for reuse by other records. Managing this memory cleanup can be complex....

Frequently Asked Question on Primary Indexing – FAQs

Can we build two primary indexes on a file?...