Consider a join (relation algebra) between relations r(R)and s(S) 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 size(r(R))
Consider a join (relation algebra) between relations r(R)and s(S) 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 size(r(R))<size(s(S)), the join will have fewer number of disk block accesses if Correct Answer relation r(R) is in the outer loop.
Concept:
Nested loop join algorithm:
No of block transfers = nr x bs + br
Where nr is number of tuples in relation R and bs and br are the number of blocks in relation R and S respectively.
Explanation :
In question it is given that size(r(R))<size(s(S)) this means bs > br and nr < ns .
Example :
Suppose relation r is in the outer loop:
[ alt="F1 R.S 14.7.20 Pallavi D2" src="//storage.googleapis.com/tb-img/production/20/07/F1_R.S_14.7.20_Pallavi_D2.png" style="width: 262px; height: 372px;">
Suppose relation s is in the outer loop:
Block transfer = 100 x 10 + 20 = 1020
So relation r should be in the outer loop for effective nested loop join algorithm.
Hence option 1 is the correct answer.
