CS FundamentalsVery hardGATE CS (PYQ pattern)
Relations R (1000 tuples), S (2000), T (500). Join selectivities: R–S 0.001, S–T 0.01, R–T 0.0005 (fraction of the cross product that qualifies). A left-deep plan joins two relations first and then the third; the cost of a plan is the size of its first (intermediate) result. What is the smallest intermediate result size over all choices of the first pair?
- A. 10000
- B. 250
- C. 2000
- D. 5000
Correct answer: B. 250
First joins: R⋈S = 1000 x 2000 x 0.001 = 2000; S⋈T = 2000 x 500 x 0.01 = 10000; R⋈T = 1000 x 500 x 0.0005 = 250. The smallest is 250.
More DBMS and SQL questions
- Sort-merge join of R (1000 pages) and S (400 pages) with 20 buffer pages. Each relation is fully sorted by external merge sort (pass 0…
- The owner O of a table issues, in this order (with GRANT OPTION each time): 1) O grants SELECT to A; 2) O grants SELECT to B; 3) A grants…
- ACC(id, bal): (1,100), (2,200), (3,300), (4,400). A row-level trigger AFTER UPDATE ON ACC FOR EACH ROW WHEN NEW.bal > 250 inserts (NEW.id…
- K(a UNIQUE, b CHECK (b > 0)) is empty. These rows are inserted one by one, ignoring any row that violates a constraint: (1,5), (1,6)…
- G(g, x): (a,5), (a,7), (b,4), (b,4), (b,4), (c,20), (d,NULL), (d,1). How many groups does SELECT g FROM G GROUP BY g HAVING SUM(x) >…
- SALE(r, q, amt): (n,1,10), (n,2,30), (s,1,5), (s,2,5), (s,3,5), (e,1,50). View V is SELECT r, SUM(amt) AS tot, COUNT() AS c FROM SALE…