Slideshow:
Important fact about the join (⋈) operator:
We can compute R ⋈ S by: storing all joining tuples of R in memory and scan S (using 1 buffer):
And then:
And so on...
(To alleviate the worst case scenario, we can use the nested-loop algorithm which will scan S multiple times)
because the compare operation can only be performed on data stored in memory
Example:
R = { (a, 1), (a, 2), (a, 3), (b, 5), (b, 7), ... } S = { (a, 8), (a, 9), (b, 1), (b, 4), ... } To compute R ⋈ S, these sets of tuples must reside in memory: a: (a, 1), (a, 2), (a, 3) (a, 8), (a, 9) b: (b, 5), (b, 7) (b, 1), (b, 4) ..: ...
then all joining tuples (e.g.: all tuples that join on the value y2) must reside in memory (but not all of them need to be in memory simultaneously):
Then:
even if R and S are sorted (sorting does not help (already sorted)) !!!!
Comment:
(and use 1 buffer to scan the tuples of relation S)
See: click here