Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.

Similar presentations


Presentation on theme: "Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization."— Presentation transcript:

1 Copyright © 2004 Pearson Education, Inc.

2 Chapter 15 Algorithms for Query Processing and Optimization

3 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-3 FIGURE 15.1 Typical steps when processing a high- level query.

4 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-4 FIGURE 15.2 Outline of the sort-merge algorithm for external sorting.

5 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-5 FIGURE 15.3 Implementation JOIN, PROJECT, UNION, INTERSECTION, and SET DIFFERENCE by using sort- merge, where R has n tuples and S has m tuples. (a) Implementing the operation T  R A=B S.

6 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-6 FIGURE 15.3 (continued) Implementation JOIN, PROJECT, UNION, INTERSECTION, and SET DIFFERENCE by using sort- merge, where R has n tuples and S has m tuples. (b) Implementing the operation T   (R).

7 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-7 FIGURE 15.3 (continued) Implementation JOIN, PROJECT, UNION, INTERSECTION, and SET DIFFERENCE by using sort- merge, where R has n tuples and S has m tuples. (c) Implementing the operation T  R  S.

8 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-8 FIGURE 15.3 (continued) Implementation JOIN, PROJECT, UNION, INTERSECTION, and SET DIFFERENCE by using sort- merge, where R has n tuples and S has m tuples. (d) Implementing the operation T  R  S.

9 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-9 FIGURE 15.3 (continued) Implementation JOIN, PROJECT, UNION, INTERSECTION, and SET DIFFERENCE by using sort- merge, where R has n tuples and S has m tuples. (e) Implementing the operation T  R – S.

10 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-10 FIGURE 15.4 Two query trees for the query Q2. (a) Query tree corresponding to the relational algebra expression for Q2.

11 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-11 FIGURE 15.4 (continued) Two query trees for the query Q2. (b) Initial (canonical) query tree for SQL query Q2.

12 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-12 FIGURE 15.4 (continued) Two query trees for the query Q2. (c) Query graph for Q2.

13 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-13 FIGURE 15.5 Steps in converting a query tree during heuristic optimization. (a) Initial (canonical) query tree for SQL query Q.

14 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-14 FIGURE 15.5 (continued) Steps in converting a query tree during heuristic optimization. (b) Moving SELECT operations down the query tree.

15 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-15 FIGURE 15.5 (continued) Steps in converting a query tree during heuristic optimization. (c) Applying the more restrictive SELECT operation first.

16 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-16 FIGURE 15.5 (continued) Steps in converting a query tree during heuristic optimization. (d) Replacing CARTESIAN PRODUCT and SELECT with JOIN operations.

17 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-17 FIGURE 15.5 (continued) Steps in converting a query tree during heuristic optimization. (e) Moving PROJECT opeations down the query tree.

18 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-18 FIGURE 15.6 A query tree for query Q1.

19 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-19 FIGURE 15.7 Two left-deep (join) query trees.

20 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 15-20 FIGURE 15.8 Sample statistical information for relations in Q2. (a) Column information. (b) Table information. (c) Index information.


Download ppt "Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization."

Similar presentations


Ads by Google