QUERY OPTIMIZATION.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Advertisements

พีชคณิตแบบสัมพันธ์ (Relational Algebra) บทที่ 3 อ. ดร. ชุรี เตชะวุฒิ CS (204)321 ระบบฐานข้อมูล 1 (Database System I)
Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.
Databases and Information Systems 1 Prof. Dr. Stefan Böttcher Fakultät EIM, Institut für Informatik Universität Paderborn WS 2009 / 2010 Contents: selectivity.
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
1 CSE 480: Database Systems Lecture 22: Query Optimization Reference: Read Chapter 15.6 – 15.8 of the textbook.
Query Optimization Dr. Karen C. Davis Professor School of Electronic and Computing Systems School of Computing Sciences and Informatics.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 19 Algorithms for Query Processing and Optimization.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 19 Algorithms for Query Processing and Optimization.
CS 257, Spring’08 Presented By: Presented By: Gayatri Gopalakrishnan Gayatri Gopalakrishnan ID : 201.
CS263 Lecture 19 Query Optimisation.  Motivation for Query Optimisation  Phases of Query Processing  Query Trees  RA Transformation Rules  Heuristic.
QUERY OPTIMIZATION AND QUERY PROCESSING.
ACS-4902 Ron McFadyen Chapter 15 Algorithms for Query Processing and Optimization.
Introduction to Query Processing and Query Optimization Techniques
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
Jan. 2014Dr. Yangjun Chen ACS Query Processing and Optimization Outline (Ch. 18, 3 rd – Ch. 15, 4 th ed. 5 th ed., Ch 19, 6 th ed.) Processing a.
ACS-4902 Ron McFadyen Chapter 15 Algorithms for Query Processing and Optimization See Sections 15.1, 2, 3, 7.
ICS (072)Query Processing and Optimization 1 Chapter 15 Algorithms for Query Processing and Optimization ICS 424 Advanced Database Systems Dr.
Query Optimization. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
Algorithms for Query Processing and Optimization
Chapter 19 Query Processing and Optimization
©Silberschatz, Korth and Sudarshan14.1Database System Concepts 3 rd Edition Chapter 14: Query Optimization Overview Catalog Information for Cost Estimation.
Query Processing Presented by Aung S. Win.
Ján GENČI PDT 2009 Systém riadenia bázy dát (Database Management System)
Database Management 9. course. Execution of queries.
Department of Computer Science and Engineering, HKUST Slide Query Processing and Optimization Query Processing and Optimization.
Query Optimization Chap. 19. Evaluation of SQL Conceptual order of evaluation – Cartesian product of all tables in from clause – Rows not satisfying where.
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
Query Processing and Optimization
Algorithms for Query Processing and Optimization
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
RELATIONAL ALGEBRA CHAPTER 6 1. LECTURE OUTLINE  Unary Relational Operations: SELECT and PROJECT  Relational Algebra Operations from Set Theory  Binary.
Lecture 11: Query processing and optimization Jose M. Peña
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
Query Processing Bayu Adhi Tama, MTI. 1 ownerNoclient © Pearson Education Limited 1995, 2005.
Chapter 18 Query Processing. 2 Chapter - Objectives u Objectives of query processing and optimization. u Static versus dynamic query optimization. u How.
1 Chapter 18 Query Processing and Optimization Query Processing and Optimization Scanner: identify language components. keywords, attribute,
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Query Processing – Query Trees. Evaluation of SQL Conceptual order of evaluation – Cartesian product of all tables in from clause – Rows not satisfying.
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Advance Database Systems Query Optimization Ch 15 Department of Computer Science The University of Lahore.
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Introduction to Query Processing (1) Query optimization: The process of choosing a suitable execution.
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
Chapter 18 Query Processing and Optimization. Chapter Outline u Introduction. u Using Heuristics in Query Optimization –Query Trees and Query Graphs –Transformation.
Chapter 13: Query Processing
Query Processing COMP3017 Advanced Databases Nicholas Gibbins
Copyright © 2011 Ramez Elmasri and Shamkant Navathe CPSC 8620: Database Management System Design Notes 7 Query Processing.
Relational Algebra National University of Computer and Emerging Sciences Lecture # 6 June 30,2012.
Query Processing and Query Optimization Database System Implementation CSE 507 Slides adapted from Silberschatz, Korth and Sudarshan Database System Concepts.
Gergely Lukács Pázmány Péter Catholic University
CHAPTER 19 Query Optimization. CHAPTER 19 Query Optimization.
Algorithms for Query Processing and Optimization
Query Processing and Optimization
Query Processing and Optimization, and Database Tuning
Query Optimization Heuristic Optimization
COMP3017 Advanced Databases
Database System Implementation CSE 507
The Relational Algebra and Relational Calculus
Query Optimization Phases of query processing
Trees 4 The B-Tree Section 4.7
The Relational Algebra and Relational Calculus
Query processing and optimization
1/3/2019.
Advance Database Systems
Monday, 5/13/2002 Hash table indexes, query optimization
Query Optimization Highlights
Algorithms for Query Processing and Optimization
Presentation transcript:

QUERY OPTIMIZATION

Find the last names of employees born after 1957 who work on a project named ‘Aquarius’. SQL > SELECT Lname FROM EMPLOYEE, WORKS_ON, PROJECT WHERE Pname=‘Aquarius’ AND Pnumber=Pno AND Essn=Ssn AND Bdate > ‘1957-12-31’;

Initial (canonical) query tree for SQL query. SELECT Lname FROM EMPLOYEE, WORKS_ON, PROJECT WHERE Pname=‘Aquarius’ AND Pnumber=Pno AND Essn=Ssn AND Bdate > ‘1957-12-31’;

Moving SELECT operations down the query tree SELECT Lname FROM EMPLOYEE, WORKS_ON, PROJECT WHERE Pname=‘Aquarius’ AND Pnumber=Pno AND Essn=Ssn AND Bdate > ‘1957-12-31’;

Applying the more restrictive SELECT operation first. SELECT Lname FROM EMPLOYEE, WORKS_ON, PROJECT WHERE Pname=‘Aquarius’ AND Pnumber=Pno AND Essn=Ssn AND Bdate > ‘1957-12-31’;

Replacing CARTESIAN PRODUCT and SELECT with JOIN operations SELECT Lname FROM EMPLOYEE, WORKS_ON, PROJECT WHERE Pname=‘Aquarius’ AND Pnumber=Pno AND Essn=Ssn AND Bdate > ‘1957-12-31’;

Moving PROJECT operations down the query tree SELECT Lname FROM EMPLOYEE, WORKS_ON, PROJECT WHERE Pname=‘Aquarius’ AND Pnumber=Pno AND Essn=Ssn AND Bdate > ‘1957-12-31’;

General Transformation Rules for Relational Algebra Operations

General Transformation Rules for Relational Algebra Operations

General Transformation Rules for Relational Algebra Operations

Outline of a Heuristic Algebraic Optimization Algorithm Using Rule 1, break up any SELECT operations with conjunctive conditions into a cascade of SELECT operations. This permits a greater degree of freedom in moving SELECT operations down different branches of the tree. Using Rules 2, 4, 6, and 10 concerning the commutativity of SELECT with other operations, move each SELECT operation as far down the query tree as is permitted by the attributes involved in the select condition.

Outline of a Heuristic Algebraic Optimization Algorithm Using Rules 5 and 9 concerning commutativity and associativity of binary operations, rearrange the leaf nodes of the tree using the following criteria. First, position the leaf node relations with the most restrictive SELECT operations so they are executed first in the query tree representation. The definition of most restrictive SELECT can mean either the ones that produce a relation with the fewest tuples or with the smallest absolute size Make sure that the ordering of leaf nodes does not cause CARTESIAN PRODUCT operations; Using Rule 12, combine a CARTESIAN PRODUCT operation with a subsequent SELECT operation in the tree into a JOIN operation, if the condition represents a join condition.

Outline of a Heuristic Algebraic Optimization Algorithm Using Rules 3, 4, 7, and 11 concerning the cascading of PROJECT and the commuting of PROJECT with other operations, break down and move lists of projection attributes down the tree as far as possible by creating new PROJECT operations as needed. Only those attributes needed in the query result and in subsequent operations in the query tree should be kept after each PROJECT operation. Identify subtrees that represent groups of operations that can be executed by a single algorithm.

Cost Components for Query Execution Access cost to secondary storage Disk Storage Cost Computation Cost Memory Usage Cost Communication Cost