34 Chapter 12 Query Processing and Query Optimization (Chapters 12 and 13)
12.25 Suppose you want to compute the results of all the following queries:
12.26 Suppose you want to compute a groupby on a relation, where you believe the
number of groups is likely to be much smaller than memory, but aren’t 100%
12.27 Suppose you have a huge relation and want to do a groupby and find groups
whose count is greater than 1 percent of the size of the relation. The total num-
12.28 Consider a block nested loop join, where memory has M
+
1 pages. Let the
relations
r
and s have
b
r
and
b
s
pages. Suppose we divide memory as follows:
one page for output,
i
pages for
r
and M −
i
pages for s.
a. What is the cost of block nested loop join of
r
and s, with
r
as the outer
relation.
b. Based on your cost formula, what value of
i
gives the lowest cost.
c. If you could choose which of
r
and s is the outer relation, how would
you
choose it?
. . .8
12.29 Consider a join
r
✶
s, where both
r
and s are pipelined in (that is, they are gen-
erated by other operations, and are piped in a tuple at a time). Let the schemas
12.30 Consider the issue of interesting orders in
optimization.
Given a set of relations
S to be joined, and a subset
S1
of S, what are the interesting orders of
S1? . .
.4
12.31 a. Suppose the number of interesting orders for a query (and each of its inter-
mediate relations) is “d”. Suppose also that there is only one join method
available. Consider a join of 2n relations.
i. What is the number of different left-deep join trees.
. . .2
ii. How many different plans does the System R optimizer actually
exam-