edited by
20,848 views
45 votes
45 votes

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 $\text{size}(r(R))<\text{size}(s(S)),$ the join will have fewer number of disk block accesses if

  1. relation $r(R)$ is in the outer loop.
  2. relation $s(S)$ is in the outer loop.
  3. join selection factor between $r(R)$ and $s(S)$ is more than $0.5$.
  4. join selection factor between $r(R)$ and $s(S)$ is less than $0.5$.
edited by

6 Answers

0 votes
0 votes

The answer is option $\left ( A\right )$

But there is a misconception in the explanations given so far which I am rectifying here.

I take the example given in Database System Concepts, 5th Edition, Silberschatz Et.al

Number of records of customer: $n_{customer_{}} = 10,000$

Number of blocks of customer: $b_{customer_{}} = 400$ 

Number of records of depositor: $n_{depositor_{}} = 5,000 $

Number of blocks of depositor: $b_{depositor_{}} = 100$ 

Consider the Formula for number of Block Transfer $\left ( n_{r}\times b_{s} \right )+b_{r}$ , Where $r$ is outer relation and $s$ is the inner relation.

Now consider $r\Rightarrow depositor$ and $s\Rightarrow customer$ (That is $depositor$ is the smaller and considered as outer relation)

By substituting values $\left ( 5000\times 400 \right )+100 = 20,00,100$

Now consider $r\Rightarrow customer$ and $s\Rightarrow depositor$ (That is $customer$ is the larger and considered as outer relation)

By substituting values $\left ( 10000\times 100 \right )+400 = 10,00,400$

So by observing this example, it is obvious that even if we consider the outer table to be smaller, the number of block transfer seems to be higher than considering the outer table to be larger.

But if you observe the question carefully, they are asking about Block Access (in particular Block Seek) rather than asking Block Transfer.

So the Number of Block Seek is $n_{r}+b_{r}$ and this is minimized only when outer relation $r$ is smaller.

Form the above example 

$r\Rightarrow depositor :$ $n_{r}+b_{r} = 5000+100 = 5,100$

$r\Rightarrow customer :$ $n_{r}+b_{r} = 10000+400 = 10,400$

$\therefore$ Option $\left ( A\right )$

 

–1 votes
–1 votes

(D) join selection factor between $r(R)$ and $s(S)$ is less than 0.5.

it does not matter if 10 x 20 or 20 x 10 answer is still the same. If the jon selection factor is less that means we will fewer record in the result relation

 

Answer:

Related questions

61 votes
61 votes
3 answers
2
33 votes
33 votes
3 answers
3
go_editor asked Sep 28, 2014
7,319 views
Given an instance of the STUDENTS relation as shown as below$$\begin{array}{|c|c|c|c|c|} \hline \textbf {StudentID} & \textbf{StudentName} & \textbf{StudentEmail} & \text...
34 votes
34 votes
8 answers
4
go_editor asked Sep 28, 2014
11,528 views
The maximum number of superkeys for the relation schema $R(E,F,G,H)$ with $E$ as the key is _____.