GATE / CS ARCHIVE

GATE CSE 2014 SET 2 / QUESTION 30

GATE CSE 2014 Set 2 Q30

Database Management Systems · Indexing, Storage & Query Processing · Full GATE CSE 2014 Set 2 paper

GATE 2014 Set 2, Q30 2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Indexing, Storage & Query Processing

Question 30, GATE 2014: A nested-loop relational join combines r(R) and s(S), with size(r)<size(s). There are three disk-block-sized buffers, one reserved for intermediate output. Which yields fewer disk-block accesses? A r in the outer loop; B s in the outer loop; C join selectivity above 0.5; D join selectivity below 0.5.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Set up the reasoning. With two input buffers, scan the inner relation once for each outer block. For block counts br and bs, compare br+br·bs with bs+bs·br, ignoring common output writes.

2. Derive the result. With one input-block buffer for each relation and one output buffer, block nested loops cost b_outer+b_outer·b_inner reads, excluding common output cost. The product is unchanged by swapping, but the initial outer scan is smaller when r is outer. Thus A, interpreting size as disk-block count.

3. Check the interpretation. The product cost is symmetric, but the one-time outer scan is not. The smaller block-count relation is therefore the better outer input. Selectivity can change result size but does not remove the specified nested-loop input scans.

Original paper, page 37 · Answer key