Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and...
-
Upload
joslyn-diffey -
Category
Documents
-
view
216 -
download
1
Transcript of Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and...
![Page 1: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/1.jpg)
Copyright © 2004 Pearson Education, Inc.
![Page 2: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/2.jpg)
Copyright © 2004 Pearson Education, Inc.
Chapter 15
Algorithms for Query Processing and
Optimization
![Page 3: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/3.jpg)
Slide 15-3Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.1Typical steps when processing a high-level query.
![Page 4: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/4.jpg)
Slide 15-4Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.2Outline of the sort-merge algorithm for external sorting.
![Page 5: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/5.jpg)
Slide 15-5Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.3Implementation 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 <project> A=BS.
![Page 6: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/6.jpg)
Slide 15-6Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
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 <attribute list>(R).
![Page 7: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/7.jpg)
Slide 15-7Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
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.
![Page 8: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/8.jpg)
Slide 15-8Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
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.
![Page 9: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/9.jpg)
Slide 15-9Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
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.
![Page 10: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/10.jpg)
Slide 15-10Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.4Two query trees for the query Q2. (a) Query tree corresponding to the relational algebra expression for Q2.
![Page 11: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/11.jpg)
Slide 15-11Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.4 (continued)Two query trees for the query Q2. (b) Initial (canonical) query tree for SQL query Q2.
![Page 12: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/12.jpg)
Slide 15-12Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.4 (continued)Two query trees for the query Q2. (c) Query graph for Q2.
![Page 13: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/13.jpg)
Slide 15-13Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.5Steps in converting a query tree during heuristic optimization. (a) Initial (canonical) query tree for SQL query Q.
![Page 14: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/14.jpg)
Slide 15-14Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.5 (continued)Steps in converting a query tree during heuristic optimization. (b) Moving SELECT operations down the query tree.
![Page 15: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/15.jpg)
Slide 15-15Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.5 (continued)Steps in converting a query tree during heuristic optimization. (c) Applying the more restrictive SELECT operation first.
![Page 16: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/16.jpg)
Slide 15-16Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.5 (continued)Steps in converting a query tree during heuristic optimization. (d) Replacing CARTESIAN PRODUCT and SELECT with JOIN operations.
![Page 17: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/17.jpg)
Slide 15-17Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.5 (continued)Steps in converting a query tree during heuristic optimization. (e) Moving PROJECT opeations down the query tree.
![Page 18: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/18.jpg)
Slide 15-18Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.6A query tree for query Q1.
![Page 19: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/19.jpg)
Slide 15-19Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.7Two left-deep (join) query trees.
![Page 20: Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.](https://reader037.fdocuments.in/reader037/viewer/2022110205/56649c775503460f9492cc29/html5/thumbnails/20.jpg)
Slide 15-20Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition
Copyright © 2004 Pearson Education, Inc.
FIGURE 15.8Sample statistical information for relations in Q2. (a) Column information. (b) Table information. (c) Index information.