Q1 Introduction (Total marks for Q1: 5 marks) Consider two relations A and B. A has…
Private research annotation
Sign in to add a private research label or note.
- User
Q1 Introduction (Total marks for Q1: 5 marks)
Consider two relations A and B. A has 80,000 tuples, and B has 100,000 tuples. Both relations store 100 tuples per page. Consider the following SQL statement:
SELECT *
FROM A INNER JOIN B
codeON A.a = B.a;We wish to evaluate an equijoin between A and B, with an equality condition A.a = B.a. There are 102 buffer pages available for this operation. Both relations are stored as (unsorted) heap files. Neither relation has any indexes built on it.
Consider the alternative join strategies described below and calculate the cost of each alternative. Evaluate the algorithms using the number of disk I/O's (i.e., pages) as the cost.
Page-oriented Nested Loops Join. Consider A as the outer relation. (1 mark) Block-oriented Nested Loops Join. Consider A as the outer relation. (1 mark) Sort-Merge Join. Assume that Sort-Merge Join can be done in 2 passes. (1 mark) Hash Join (1 mark) Assuming that no indexes are built on any of the two relations, and assuming that sufficient buffer space is available: What would be the lowest possible cost to perform this query ? (0.5 mark) What would be the minimum buffer size required to achieve this cost from 5A? (0.5 mark)
- Assistant
Let's evaluate each join strategy based on the given parameters:
-
Page-oriented Nested Loops Join (A as outer):
- Cost Calculation:
- Pages in A: 80,000 tuples / 100 tuples per page = 800 pages
- Pages in B: 100,000 tuples / 100 tuples per page = 1,000 pages
- Cost Calculation:
-