Simple Hash Join (cont)
Algorithm for simple hash join Join[R.i=S.j](R,S):
for each tuple r in relation R {
if (buffer[h(R.i)] is full) {
for each tuple s in relation S {
for each tuple rr in buffer[h(S.j)] {
if ((rr,s) satisfies join condition) {
add (rr,s) to result
} } }
clear all hash table buffers
}
insert r into buffer[h(R.i)]
}
|
# join tests ≤ rS.cR
(cf. nested-loop rS.rR)
# page reads depends on #buffers N and properties of data/hash.
|