

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


100 Points
Due November 24th, at the beginning of class. Typed solutions preferred. If hand-written, solutions must be legible.
Query Evaluation and Optimization
(a) σa< 50000 (R) (b) σa=50000(R) (c) σa> 50000 ∧a< 50010 (R) (d) σa 6 =50000(R)
(a) How many runs will you produce in the first pass? (b) How many passes will it take to sort the file completely? (c) What is the total I/O cost of sorting the file? (d) How many buffer pages do you need to sort the file completely in just two passes?
(a) What is the cost of joining R and S using a page-oriented simple nested loops join? What is the minimum number of buffer pages required for this cost to remain unchanged? (b) What is the cost of joining R and S using a block nested loops join? What is the minimum number of buffer pages required for this cost to remain unchanged? (c) What is the cost of joining R and S using a sort-merge join? What is the minimum number of buffer pages required for this cost to remain unchanged? (d) What is the cost of joining R and S using a hash join? (e) What would be the lowest possible I/O cost for joining R and S using any join algorithm, and how much buffer space would be needed to achieve this cost? Explain briefly. (f) How many tuples does the join of R and S produce, at most, and how many pages are required to store the result of the join back on disk? (g) If you were told that R.a is a foreign key that refers to S.b, for which of the four join algorithms above would the join costs change?
Consider the following query: SELECT E.title, E.ename FROM Executives E WHERE E.title=CFO Assume that only 10% of Executives tuples meet the selection condition.
(a) Suppose that a clustered B+ tree index on title is (the only index) available. What is the cost of the best plan? (In this and subsequent questions, be sure to describe the plan you have in mind.) (b) Suppose that an unclustered B+ tree index on title is (the only index) available. What is the cost of the best plan? (c) Suppose that a clustered B+ tree index on ename is (the only index) available. What is the cost of the best plan? (d) Suppose that a clustered B+ tree index on address is (the only index) available. What is the cost of the best plan? (e) Suppose that a clustered B+ tree index on <ename, title> is (the only index) available. What is the cost of the best plan?