The Gateway to Computer Science Excellence
+1 vote
Assume that a data file contains 1000 records that are ordered by a key
attribute A, and a primary index on attribute A is built. Let the size of
key be 5B and block pointer be 5B. Each block of the system is of 105B,
out of which 100B can be used to store data and 5B is reserved for storing
meta data. How many disk accesses will be required to fetch the record using the
index in average case?

 a. 6

 b. 3

 c. 4

 d. 5

in Databases by | 418 views

1 Answer

+2 votes
Best answer
a block of file store 100/5=20 record

so no of block required to store file=1000/20=50 block

so we create primary index on 50 block means primary index contain 50 entry

size of one entry of primary index=5B (for key)+5B (for block pointer)=10B

one block can store 100/10=10 entry of index

no of block req to store index=50/10=5

searching an entry in index use binary serarch require log(5) block access>2 means 3 at worst case

+1 for finding key in data file

so total 4 block access required
selected by
why 100/5?


Yes , it is 100/5 , obviously .

Each block of the system is of 105B, out of which 100B can be used to store data and 5B is reserved for storing meta data

That means , it indirectly says  Block size = 100 B ( as block contain data only ) . 100 B can use to hold total data . total data = block size.

meta data size is 5 B  this is size of each single record 

so, size of each record is 5 B .



sir why we are not creating one more level consisting index of these 5 blocks?

This way disk access will reduce to 3 .

Plz help.


Updated Link:

Here, I think they have considered Record size to be 10 B.


Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,375 questions
60,571 answers
95,387 users