Skip to main content

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…

Consider a file of 16384 records. Each record is 32  bytes32\;\text{bytes} long and its key field is of size 6  bytes6\;\text{bytes}. 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 1024  bytes1024\;\text{bytes}, and the size of a block pointer is 10  bytes10\;\text{bytes}. 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

  1. A
    8 and 0
  2. B
    128 and 6
  3. C
    256 and 4
    Correct answer
  4. D
    512 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.