Consider a join (relation algebra) between relations and using the nested loop method. There are 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
View worked solution
Answer: A
To perform a block-nested loop join with available buffers where buffer is reserved for the output (intermediate results), we have buffers remaining for the relations.
With buffers available for the join:
- buffer is allocated to hold a block of the outer relation.
- buffer is allocated to scan the blocks of the inner relation.
Let and be the number of disk blocks occupied by relations and respectively. Since , we have .
Let's compare the total disk block accesses for both configurations:
- Case 1: is in the outer loop
Each block of is read once, and for each of these blocks, the entire relation is scanned.
- Case 2: is in the outer loop
Each block of is read once, and for each of these blocks, the entire relation is scanned.
Comparing the two costs:
Since , we have:
Thus, the join will require fewer disk block accesses if the smaller relation is kept in the outer loop.
Free practice · Your answers on this page are not saved.
