Query Optimization and Perspectives

Slides:



Advertisements
Similar presentations
Query Optimization Reserves Sailors sid=sid bid=100 rating > 5 sname (Simple Nested Loops) Imperative query execution plan: SELECT S.sname FROM Reserves.
Advertisements

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.
Query Optimization May 31st, Today A few last transformations Size estimation Join ordering Summary of optimization.
Query Optimization CS634 Lecture 12, Mar 12, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
Distributed DBMS© M. T. Özsu & P. Valduriez Ch.6/1 Outline Introduction Background Distributed Database Design Database Integration Semantic Data Control.
Query Optimization Goal: Declarative SQL query
Query Optimization. Query Optimization Process (simplified a bit) Parse the SQL query into a logical tree: –identify distinct blocks (corresponding to.
Query Optimization: Transformations May 29 th, 2002.
CMSC724: Database Management Systems Instructor: Amol Deshpande
Summary. Chapter 9 – Triggers Integrity constraints Enforcing IC with different techniques –Keys –Foreign keys –Attribute-based constraints –Schema-based.
Query Optimization. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
T HE Q UERY C OMPILER Prepared by : Ankit Patel (226)
Query Processing Presented by Aung S. Win.
Access Path Selection in a Relational Database Management System Selinger et al.
CS411 Database Systems Kazuhiro Minami 12: Query Optimization.
Database Management 9. course. Execution of queries.
Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for 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.
Query Optimization March 10 th, Very Big Picture A query execution plan is a program. There are many of them. The optimizer is trying to chose a.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 4: Intermediate.
1 Lecture 25 Friday, November 30, Outline Query execution –Two pass algorithms based on indexes (6.7) Query optimization –From SQL to logical.
CS411 Database Systems Kazuhiro Minami 12: Query Optimization.
1 Final Review Tuesday, March 6, The Final Date: Tuesday, March 13, 2007 Time: 6:30 - 8:30 Room: EE 037 You must come to campus Open book exam.
Query Processing – Query Trees. Evaluation of SQL Conceptual order of evaluation – Cartesian product of all tables in from clause – Rows not satisfying.
1 Announcements Reading for next week: Chapter 4 Your first homework will be assigned as soon as your database accounts have been set up.  Expect an .
1 Lecture 25: Query Optimization Wednesday, November 26, 2003.
CS 440 Database Management Systems Query Optimization 1.
Lecture 15: Query Optimization. Very Big Picture Usually, there are many possible query execution plans. The optimizer is trying to chose a good one.
CSE 544: Lecture 14 Wednesday, 5/15/2002 Optimization, Size Estimation.
Tallahassee, Florida, 2016 COP5725 Advanced Database Systems Query Optimization Spring 2016.
CHAPTER 19 Query Optimization. CHAPTER 19 Query Optimization.
Chapter 14: Query Optimization
CS 440 Database Management Systems
Query Optimization Heuristic Optimization
Course Introduction 공학대학원 데이타베이스
Lecture 26: Query Optimizations and Cost Estimation
Prepared by : Ankit Patel (226)
CPSC-310 Database Systems
Chapter 4: Intermediate SQL Joins
Introduction to Query Optimization
Introduction to Database Systems CSE 444 Lecture 22: Query Optimization November 26-30, 2007.
Lecture 26: Query Optimization
Query Processing B.Ramamurthy Chapter 12 11/27/2018 B.Ramamurthy.
Outline Introduction Background Distributed DBMS Architecture
Introduction to Database Systems CSE 444 Lecture 23: Final Review
Database management concepts
Chapter 4 The Relational Model Pearson Education © 2009.
Lecture 27: Optimizations
Lecture 30: Final Review Wednesday, December 6, 2000.
Contents Preface I Introduction Lesson Objectives I-2
A Framework for Testing Query Transformation Rules
Chapter 4 The Relational Model Pearson Education © 2009.
Lecture 30: Final Review Wednesday, December 10, 2003.
Query Optimization.
Monday, 5/13/2002 Hash table indexes, query optimization
Distributed Database Management Systems
Query Optimization March 7th, 2003.
Query Processing.
Introduction to Database Systems CSE 444 Lecture 23: Final Review
CSE 544: Optimizations Wednesday, 5/10/2006.
Lecture 26 Monday, December 3, 2001.
Final Review Friday, December 8, 2006.
Lecture 26: Wednesday, December 4, 2002.
Course Instructor: Supriya Gupta Asstt. Prof
Lecture 27 Wednesday, December 5, 2001.
Lecture 29: Final Review Wednesday, December 11, 2002.
Lecture 24: Wednesday, November 27, 2002.
Presentation transcript:

Query Optimization and Perspectives March 12th, 2003

Administration Exam next Wednesday, 2:30pm. Special office hours next week will be announced.

Problem Given: a query R1 R2 … Rn Assume we have a function cost() that gives us the cost of every join tree Find the best join tree for the query

Dynamic Programming For each subquery Q ⊆ {R1, …, Rn} compute the following: Size(Q) A best plan for Q: Plan(Q) The cost of that plan: Cost(Q)

Dynamic Programming Step 1: For each {Ri} do: Size({Ri}) = B(Ri) Plan({Ri}) = Ri Cost({Ri}) = (cost of scanning Ri)

Dynamic Programming Step i: For each Q ⊆ {R1, …, Rn} of cardinality i do: Compute Size(Q) For every pair of subqueries Q’, Q’’ s.t. Q = Q’ U Q’’ compute cost(Plan(Q’) Plan(Q’’)) Cost(Q) = the smallest such cost Plan(Q) = the corresponding plan

Dynamic Programming Return Plan({R1, …, Rn})

Dynamic Programming Summary: computes optimal plans for subqueries: Step 1: {R1}, {R2}, …, {Rn} Step 2: {R1, R2}, {R1, R3}, …, {Rn-1, Rn} … Step n: {R1, …, Rn} We used naïve size/cost estimations In practice: more realistic size/cost estimations heuristics for Reducing the Search Space Restrict to left linear trees Restrict to trees “without cartesian product” need more than just one plan for each subquery: “interesting orders”

Plan with Materialization HashTable  S repeat read(R, x) y  join(HashTable, x) write(V1, y) HashTable  T repeat read(V1, y) z  join(HashTable, y) write(V2, z) HashTable  U repeat read(V2, z) u  join(HashTable, z) write(Answer, u) ⋈ V2 ⋈ U V1 ⋈ T R S

Plan with Pipelining ⋈ ⋈ U ⋈ T R S pipeline HashTable1  S HashTable2  T HashTable3  U repeat read(R, x) y  join(HashTable1, x) z  join(HashTable2, y) u  join(HashTable3, z) write(Answer, u) ⋈ U ⋈ T R S

Key Lessons in Optimization There are many approaches and many details to consider in query optimization Classic search/optimization problem! Not completely solved yet! Main points to take away are: Algebraic rules and their use in transformations of queries. Deciding on join ordering: System-R style (Selinger style) optimization. Estimating cost of plans and sizes of intermediate results.

The Course in Perspective The relational data model, SQL Views, updates, transactions Conceptual design Expressing the constraints on the domain Using them to get good schema designs XML A format for data exchange. Has its own query language. Basis for web services.

Perspective (continued) Building a database system: Storage and indexing Query execution (join algorithms) Query optimization Data integration and sharing: Databases were created independently Schemas need to be matched Need to access multiple databases in one query. Interoperability through web services.