Presentation is loading. Please wait.

Presentation is loading. Please wait.

Performance Join Operator Select * from R, S where R.a = S.a;

Similar presentations


Presentation on theme: "Performance Join Operator Select * from R, S where R.a = S.a;"— Presentation transcript:

1 Performance Join Operator Select * from R, S where R.a = S.a;
perform a cross product, followed by select and project NO -- the result can be large. What if three (or more) relations? JOIN is a binary operator Techniques: J1. Nested loops (nested blocks) join J2. Index nested loops join J3. Sort-Merge join J4. Partition-Hash join Performance 11/14/18.1

2 J2. Index Nested Loops Join
If there is an index, take advantage of it. Instead of two table scans, use one table scan and one index scan Does it matter if the index is the inner or outer loop? foreach tuple r in R foreach tuple s in S where ri = si add (r,s) to result Join selection factor: the fraction of records in one table that will be joined with records in the other table. 11/14/18.2

3 Index Nested Loops Join
foreach tuple r in R foreach tuple s in S where ri = si add (r,s) to result S has an index with depth xS = 2 rR = 6000, bR = 2000, rS = 50, bS = 10 -- nested loop: index bR + (rR * (xS + 1)) = (6000*(2+1)) = 20,000 -- outer loop: index bS*(xS+1) * bR = 10 * (2+1) * 2000 = 60,000 11/14/18.3

4 Index Index Nested Loops Join
foreach tuple r in R foreach tuple s in S where ri = si add (r,s) to result If R and S each have an index: S index depth xS = 2 and R index depth xR = 4 rR = 6000, bR = 2000, rS = 50, bS = 10 -- R outer loop bR + (rR * (xS + 1)) = (6000*(2+1)) = 20,000 -- S outer loop bS + (rS * (xR + 1)) = 10 + (50*(4+1)) = 260 11/14/18.4


Download ppt "Performance Join Operator Select * from R, S where R.a = S.a;"

Similar presentations


Ads by Google