Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Problem description:
Find the best algorithm to
execute
⋈1 and
⋈2
for M = 101 -
click to pull out
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Simplified Problem :
Solution method:
brute force search for the
min. cost algorithms that
can operate with M = 101
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Step 1:
check if
we can use a 1-pass algorithm
for ⋈1:
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Step 2:
check if
we can use a 2-pass (hashing based)
algorithm
for ⋈1:
Next,
we find the
best algorithm for
⋈2
(considering the buffer utilization of
⋈1 !)
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Determining the
buffer utilization by
the ⋈1
execution:
(⋈2 is
inactive and
will not use any
buffers)
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Determining the
buffer utilization by
the ⋈1
execution:
Next:
we run pass 2 of the
2-pass (hashing-based) algorithm
(= a 1-pass algorithm on
each Ri and Si)
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Determining the
buffer utilization by
the ⋈1
execution:
Note:
pass 2 is run
for every chunk
Ri and Si and
pass 2 will
output tuples to
⋈2
(→ becomes active !)
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Cost (so far):
Click on image to
pull out (keep running cost)
Next:
determine the best suitable
join algorithm for
⋈2
Example on selection implementation algorithm for a query plan -
B(R⋈S) medium
Prelude to considering the
implementation algorithm for
⋈2:
⋈1 is
actively using its buffers
to produce tuples for
⋈2:
I.e.:
we must find the
best algorithm for
⋈2
using M = 101 − 51 =
50 buffers !!
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Step 3:
check if
we can use a 1-pass
algorithm
for ⋈2:
Note:
I think this solution works for
B(R⋈S) ≤ 50;
but the
text book thinks it's only good for
B(R⋈S) ≤ 49
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Step 3:
check if
we can use a 1-pass
algorithm
for ⋈2:
Therefore:
⋈2
can use the
1-pass algorithm !
Note:
I think this solution works for
B(R⋈S) ≤ 50;
but the
text book thinks it's only good for
B(R⋈S) ≤ 49
Example on selection implementation algorithm for a query plan -
B(R⋈S) small
Cost analysis:
Postscript: why I think it should be
B(R⋈S) ≤ 50
You can use all the remianing 50 buffers
to build the search index on
R ⋈ S:
Postscript: why I think it should be
B(R⋈S) ≤ 50
When ⋈1 is
done, you can
free up its
buffers:
Postscript: why I think it should be
B(R⋈S) ≤ 50
Then use one buffer
(from the freed up buffers) to
scan
the relation T:
❮
❯