Review: the
Sort-Join algorithm
Pseudo code:
Use M-1 buffers and read all tuples with
the smallest join value in relation R
Use 1 buffer to scan relation S;
While ( R ≠ empty OR S ≠ empty )
{
Let r = the current smallest join value ∈ R
Let S = the current smallest join value ∈ S
if ( r < s )
{
Use M-1 buffers and read all tuples with
the next smallest join value in relation R;
}
else if ( s < r )
{
Use 1 buffer to scan to the next join value in relation S;
}
else /* join R and S */
{
Scan and join all tuples in S with join attr = r;
// Use next join value in R
Use M-1 buffers and read all tuples with
the next smallest join value in relation R;
}
}
|
IO cost of
the Sort-Join algorithm
Buffer requirement of
the Sort-Join algorithm
All joining tuples
(for a specific
join value)
of relation R
must be
contained in
(M−1) buffers:
An alternate (clever) way to use
the Sort-Join algorithm
I.e.:
we can adapt the
Sort-Join algorithm to use
an ordered index !!!
❮
❯