Chapter 19: Query Optimization
CHAPTER 19: QUERY OPTIMIZATION
Answers to Selected Questions
19.15 – Develop cost functions for the PROJECT, UNION, INTERSECTION,
SET DIFFERENCE, and CARTESIAN PRODUCT algorithms discussed in section
19.4.
Answer:
Assume relations R and S are stored in b R and b S disk blocks, respectively. Also, assume
that the file resulting from the operation is stored in b RESULT disk blocks (if the size
cannot be otherwise determined).
PROJECT operation: if <attribute list> includes a key of R, then the cost is 2*b R since the
read–in and write–out files have the same size, which is the size of R itself; if <attribute
list> does not include a key of R, then we must sort the intermediate result file before
19.16 – No solution provided.
19.18 – Calculate the cost functions for different options of executing the JOIN operation
OP7 discussed in section 19.3.2.
Answer:
The operation is
OP7: DEPARTMENT |x| MGRSSN=SSN EMPLOYEE.
As in section 18.2.3 we assume the secondary index on MGRSSN of DEPARTMENT, with
selection cardinality s=1 and level x=1; also the join selectivity of OP7 is js = 1/125 =