Consider a file of 16384 records. Each record is long and its key field is of size . The file is ordered on a non-key field, and the file organization is unspanned. The file is stored in a file system with block size , and the size of a block pointer is . If the secondary index is built on the key field of the file, and a multi-level index scheme is used to store the secondary index, the number of first-level and second-level blocks in the multi-level index are respectively
GATE CSE 2008Databases › Transactions, Concurrency Control & IndexingVerified
GATE CSE 2008 PYQ: Consider a file of 16384 16384 16384 records. Each record is 32 bytes 32\;\text{bytes} 32 bytes long and its…
- A8 and 0
- B128 and 6
- C256 and 4Correct answer
- D512 and 5
Answer
(C) 256 256 256 and 4 4 4
Approach
A secondary index on a key field is a dense index: it must contain one index entry for every record in the data file because the file itself is not ordered by the key field. Each index entry is a ⟨key, block pointer⟩ pair, so its size is the key size plus the pointer size. Compute the number of index entries per block, then form the first-level index blocks and the second-level index blocks.
The secondary index is on the key field, so it is dense and has one entry per record: 16384 entries. Each entry is 16 bytes, and each block can hold 64 entries. Therefore the first-level index requires ceil(16384/64)=256 blocks. The second level contains one entry per first-level block, i.e. 256 entries, requiring ceil(256/64)=4 blocks. Hence option C is correct.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.