Form 1:
( R ⋈ S ) ⋈ T ( S ⋈ R ) ⋈ T
( R ⋈ T ) ⋈ S ( T ⋈ R ) ⋈ S
( S ⋈ T ) ⋈ R ( T ⋈ S ) ⋈ R
Form 2:
R ⋈ ( S ⋈ T ) R ⋈ ( T ⋈ S )
S ⋈ ( R ⋈ T ) S ⋈ ( T ⋈ R )
T ⋈ ( R ⋈ S ) T ⋈ ( S ⋈ R )
|
Form 1: ( • ⋈ • ) ⋈ •
Form 2: • ⋈ ( • ⋈ • )
|
|
|
|
|
The possible left-deep join trees are:
|
|
|
|
|
|
# left deep tree = 6 (= 3!)
|
|
In other words:
|
R ⋈ S ⋈ T ⋈ U
|
using the one-pass join algorithm.
|
|
|
while ( S ≠ empty )
{
Read M - 1 blocks of S and
organize them into a search structure
(e.g., hash table)'
Rewind R;
while ( R ≠ empty )
{
Read 1 block (b) of R;
for ( each tuple t ∈ block b ) do
{
Find the tuples s1, s2, ... of S (in the search structure)
that join with t
Output (t,s1), (t,s2), ...
}
}
}
|
R ⋈ S ⋈ T ⋈ U
|
using the nested-loop join algorithm.
|
|
|
|
|