CS FundamentalsVery hardProduct company interview · GATE level
Relations R (1000 blocks) and S (200 blocks) are joined with a block nested-loop join using M = 52 buffer blocks: M - 2 blocks hold a chunk of the outer relation, one block scans the inner relation and one collects output. The cost in block reads is b(outer) + ceil(b(outer)/(M - 2)) x b(inner). What is the cheapest cost obtainable by choosing the outer relation well?
- A. 5000 block reads
- B. 4200 block reads
- C. 200,200 block reads
- D. 1200 block reads
Correct answer: B. 4200 block reads
With S as the outer relation: 200 + ceil(200/50) x 1000 = 200 + 4 x 1000 = 4200. With R as the outer relation: 1000 + ceil(1000/50) x 200 = 1000 + 20 x 200 = 5000. The smaller relation should be the outer one because it needs fewer passes over the inner relation. 200,200 is the cost with only one buffer block for the outer relation (200 + 200 x 1000); 1200 would need the whole of S to fit in memory at once.
More DBMS and SQL questions
- Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). How many rows…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- Consider the schedule W2(A), R1(A), R2(A), W3(A), R3(A), R1(C). Which statement is correct?
- TS(T1) = 25, TS(T2) = 5, TS(T3) = 30; all read/write timestamps start at 0. Under basic timestamp ordering (no Thomas write rule), which…
- R(A, B, C, D, E) has functional dependencies DE → B, C → E, D → AC. What is the highest normal form R satisfies?