CS FundamentalsVery hardGATE CS (PYQ pattern)

A Grace hash join partitions both inputs into B - 1 partitions using one input page per partition plus one input buffer; in the probe phase one partition of the SMALLER relation must fit in memory together with one page for the other relation's input and one for output (B - 2 pages for the hash table). The smaller relation has 400 pages. What is the minimum number of buffer pages B for which this two-phase algorithm works without recursive partitioning (assume perfectly even partitions)?

  1. A. 20
  2. B. 22
  3. C. 21
  4. D. 25

Correct answer: B. 22

Need ceil(400 / (B - 1)) <= B - 2. B = 21 gives ceil(400/20) = 20 > 19; B = 22 gives ceil(400/21) = 20 <= 20. The textbook shortcut sqrt(400) = 20 is too small because of the extra buffer pages.

More DBMS and SQL questions

Exams that ask this topic