Question
Consider a join (relational algebra) between relations and using the nested loop method. There are 3 buffers each of size equal to disk block size, out of which one buffer is reserved for intermediate results. Assuming , the join will have fewer number of disk block accesses if
Official answer and solution
- Official answer
- A
- From
- Official GATE 2014 answer key
Solution
Compare disk block I/O costs for block nested loop join with smaller versus larger relations in the outer loop.
-
Buffer Allocation:
- Total buffers = 3 blocks.
- 1 buffer is reserved for intermediate output results.
- Remaining available buffers for input relations = blocks (1 buffer for outer relation block, 1 buffer for inner relation block).
-
Block I/O Cost Analysis:
Let and denote the number of disk blocks occupied by relation and respectively, with .- Case 1 ( in outer loop):
- Case 2 ( in outer loop):
- Case 1 ( in outer loop):
-
Comparison:
Since , we have , which implies:
Therefore, placing the smaller relation in the outer loop results in fewer disk block accesses.
A
Thinking that join selection factor determines block I/O of nested loop joins before any index or filtering is applied.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 2
- Question
- 40 of 65, printed as CS Q.30
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.