A general buffer minimalization problem...
Problem description:
Note:
this type of problem is
harder than then ones
we need to solve for
query optimization
(see later)
Buffer minimalization problem 1:
⋈1 and ⋈2
are 1-pass
Problem description:
Problem 1:
⋈1 and
⋈2 are using
the 1-pass algorithm
Buffer minimalization problem 1:
⋈1 and ⋈2
are 1-pass
Consider the
execution of the
query plan:
Buffer minimalization problem 1:
⋈1 and ⋈2
are 1-pass
Consider the
execution of the
query plan:
Note: you
cannot free the
buffers used to
index R (B(R)) while
scanning tuples from
S
Buffer minimalization problem 1:
⋈1 and ⋈2
are 1-pass
Consider the
execution of the
query plan:
Note: you
can free the
buffers used to
index R (B(R)) because
⋈1 is
done !
Buffer minimalization problem 1:
⋈1 and ⋈2
are 1-pass
# buffers used in the
query processing in
various stages:
- ⋈1's
phase 1:
B(R) + 1
- ⋈1's
phase 2:
B(R) + 1 + B(R⋈S)
- ⋈2's
phase 1:
B(R⋈S) + 1
|
Example analysis
Statistics on the
input relations:
Find the
minimum # buffers needed to
execute the
following
query plan:
Where ⋈1 and
⋈2 are using
the 1-pass algorithm
Example analysis
Statistics on the
input relations:
Processing step 1:
Example analysis
Statistics on the
input relations:
Preparing for
processing step 2:
Example analysis
Statistics on the
input relations:
Processing step 2:
Example analysis
Statistics on the
input relations:
Processing step 3:
Minimum # buffers needed =
6001
(used in step 2 of the processing)
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
(Finding this
expression
will be a homework problem)
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
How to execute the
query plan with
1006 buffers:
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
How to execute the
query plan with
1006 buffers:
Pass 1 of
⋈2 will use
the (remaining) 5 buffers to
hash its
input into
5 (smaller) chunks
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
How to execute the
query plan with
1006 buffers:
Notice that the
chunk size is approximately
B(R⋈S)/5 = 5000/5 = 1000 blks
Notice that the
query execution is
currently using the
# available buffers...
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
How to execute the
query plan with
1006 buffers:
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
How to execute the
query plan with
1006 buffers:
We must hash the
tuples in
the 2nd relation T:
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
How to execute the
query plan with
1006 buffers:
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
How to execute the
query plan with
1006 buffers:
Notice that the
chunk size ~= 1000 blks and
we can run
the 1-pass algorithm on
each chunk !!
Buffer minimalization problem 2:
⋈1 is 1-pass and
⋈2 is 2-pass hashing
- Example
Also: you
cannot execute this
query plan using
1005 buffers !
The resulting chunks hashed will
have size = 5000/4 = 1250
> 1006 buffers !!
So you need a minumum of
1006 buffers
Postscript
Finding the
best (implementation) algorithm
is a "search" problem which is
much simpler than this
minimalization problem
❮
❯