Query Rewrite Starburst Model (IBM).

Slides:



Advertisements
Similar presentations
Northwestern University Business Intelligence Solutions Cognos 8 Best Practices Volume 3 Advanced Developer Techniques.
Advertisements

Query Optimization Reserves Sailors sid=sid bid=100 rating > 5 sname (Simple Nested Loops) Imperative query execution plan: SELECT S.sname FROM Reserves.
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
CS CS4432: Database Systems II Logical Plan Rewriting.
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
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
Paper by: A. Balmin, T. Eliaz, J. Hornibrook, L. Lim, G. M. Lohman, D. Simmen, M. Wang, C. Zhang Slides and Presentation By: Justin Weaver.
DB performance tuning using indexes Section 8.5 and Chapters 20 (Raghu)
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
1 The Optimizer How ORACLE optimizes SQL statements David Konopnicky 1997, Revised by Mordo Shalom 2004.
Database System Concepts 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 14: Query Optimization.
16.5 Introduction to Cost- based plan selection Amith KC Student Id: 109.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
What I am doing Amol Deshpande. Selection Ordering  Given a set of selection predicates and correlations between them, find the optimal ordering : Not.
Access Path Selection in a Relation Database Management System (summarized in section 2)
Query Processing Presented by Aung S. Win.
Context Tailoring the DBMS –To support particular applications Beyond alphanumerical data Beyond retrieve + process –To support particular hardware New.
Access Path Selection in a Relational Database Management System Selinger et al.
Database Management 9. course. Execution of queries.
Query Optimization. Query Optimization Query Optimization The execution cost is expressed as weighted combination of I/O, CPU and communication cost.
Department of Computer Science and Engineering, HKUST Slide Query Processing and Optimization Query Processing and Optimization.
CPS216: Advanced Database Systems Notes 08:Query Optimization (Plan Space, Query Rewrites) Shivnath Babu.
RELATIONAL FAULT TOLERANT INTERFACE TO HETEROGENEOUS DISTRIBUTED DATABASES Prof. Osama Abulnaja Afraa Khalifah
Dive into the Query Optimizer Dive into the Query Optimizer: Undocumented Insight Benjamin Nevarez Blog: benjaminnevarez.com
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Query Rewrite Starburst Model (IBM). DB2 Query Optimizer (Starburst) Parsing and Semantic Checking Query Rewrite Plan Optimization Query Evaluation System.
Query optimization in distributed database systems.
Optimization of Nested Queries Sujatha Thanigaimani COSC 6421.
Query Processing – Query Trees. Evaluation of SQL Conceptual order of evaluation – Cartesian product of all tables in from clause – Rows not satisfying.
1 Execution Strategies for SQL Subqueries Mostafa Elhemali, César Galindo- Legaria, Torsten Grabs, Milind Joshi Microsoft Corp.
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
DB Tuning : Chapter 10. Optimizer Center for E-Business Technology Seoul National University Seoul, Korea 이상근 Intelligent Database Systems Lab School of.
Query Processing – Implementing Set Operations and Joins Chap. 19.
Lecture 15: Query Optimization. Very Big Picture Usually, there are many possible query execution plans. The optimizer is trying to chose a good one.
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
1 Minggu 6, Pertemuan 12 Query Processing Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
Query Sampling in DB2. Motivation Data volume is growing fast Many algorithms do not scale up with data volume For exploratory analysis users often want.
CHAPTER 19 Query Optimization. CHAPTER 19 Query Optimization.
Chapter 14: Query Optimization
Tuning Transact-SQL Queries
UNIT 11 Query Optimization
Chapter 13: Query Optimization
Query Optimization Kush Kashyap B.Tech -IT.
Prepared by : Ankit Patel (226)
CS222P: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Lecture 24: Query Execution and Optimization
Chapter 12: Query Processing
Database Performance Tuning and Query Optimization
Chapter 15 QUERY EXECUTION.
February 7th – Exam Review
Akshay Tomar Prateek Singh Lohchubh
Practical Database Design and Tuning
Outline Introduction Background Distributed DBMS Architecture
Database Applications (15-415) DBMS Internals- Part IX Lecture 21, April 1, 2018 Mohammad Hammoud.
Query Rewrite Starburst Model (IBM).
Extensible/Rule Based Query Rewrite Optimization in Starburst
Query Rewrite Starburst Model (IBM).
Query Optimization CS 157B Ch. 14 Mien Siao.
Query Processing CSD305 Advanced Databases.
CS222P: Principles of Data Management Notes #13 Set operations, Aggregation, Query Plans Instructor: Chen Li.
Query Optimization.
Query Processing.
CS222: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Lecture 24: Wednesday, November 27, 2002.
Query Transformations
Select-From-Where Statements Multirelation Queries Subqueries
Presentation transcript:

Query Rewrite Starburst Model (IBM)

DB2 Query Optimizer (Starburst) Control Flow Parsing and Semantic Checking Data Flow Query Graph Model Query Rewrite Plan Optimization Executable Plan Compile Time Run Time Query Evaluation System

Goal of Query Rewrite Make queries as declarative as possible: Poorly expressed queries could force the optimizer into choosing suboptimal plans Perform natural heuristics For example, “predicate pushdown”

Components of Rewrite Engine Rewrite rules (more later) Rule engine control strategies sequential (rules are processed sequentially) priority (higher priority rules are given a chance first) statistical (next rule is chosen randomly based on a user defined probability distribution budget to avoid spending too much time on rewrites, the processing stops at a consistent state of QGM when the budget is exhausted Search facility browses through QGM providing the context for the rules to work on

Problem How do we choose between competing incompatible transformations? Optimal solution: apply cost analysis and pick the transformation leading to a cheaper plan Practical solution (why?): generate multiple alternatives and send them to plan optimization phase (problems?)

Rewrite Rules: SELECT Merge CREATE VIEW itpv AS (SELECT DISTINCT itp.itemn, pur.vendn FROM itp, pur WHERE itp.ponum = pur.ponum AND pur.odate > ’85’) SELECT itm.itmn, itpv.vendn FROM itm, itpv WHERE itm.itemn = itpv.itemn AND itm.itemn > ’01’ AND itm.itemn < ’20’ SELECT DISTINCT itm.itmn, pur.vendn FROM itm, itp, pur WHERE itp.ponum = pur.ponum AND itm.itemn = itpv.itemn AND pur.odate > ’85’ AND itm.itemn > ’01’ AND itm.itemn < ’20’ Speedup: 200 times

Rewrite Rules: Existential Subquery Merge SELECT * FROM itp WHERE itm.itemn IN ( SELECT itl.itmn FROM itl WHERE itl.wkcen = ‘WK468’ AND itl.locan = ‘L’) SELECT DISTINCT itp.* FROM itp, itl WHERE itp.itmn = itl.itemn AND itl.wkcen = ‘WK468’ AND itl.locan = ‘L’ Speedup: 15 times

Rewrite Rules:Intersect to Exists SELECT itemn FROM wor WHERE empno = ‘EMPN1279’ INTERSECT SELECT itmn FROM itl WHERE entry_time = ‘9773’ AND wkctr = ‘WK195’) SELECT DISTINCT itemn FROM wor, itl WHERE empno = ‘EMPN1279’ entry_time = ‘9773’ AND wkctr = ‘WK195’) AND itl.itmn = wor.itemn Speedup: 8 times

The Count Bug (cont.) parts(PNUM,QOH) supply(PNUM,QUAN,SHIPDATE) Query: Find the part numbers of those parts whose quantities on hand equal the number of shipments of those parts before 1-1-80. select PNUM from parts where QOH = ( select count(SHIPDATE) from supply where supply.PNUM = parts.PNUM and SHIPDATE < 1-1-80)

The Count Bug (cont.) select PNUM from parts where QOH = ( select count(SHIPDATE) from supply where supply.PNUM = parts.PNUM and SHIPDATE < 1-1-80) temp (SUPPNUM,CT) = (select PNUM, count(SHIPDATE) from supply where SHIPDATE < 1-1-80) group by PNUM) select PNUM from parts, temp where parts.QOH = temp.CT and temp.PNUM = parts.PNUM

The Count Bug (cont.) Parts Supply PNUM QOH 3 6 10 1 8 PNUM QUAN PNUM QUAN SHIPDATE 3 4 7-3-79 2 10-1-78 10 1 6-8-78 8-10-81 8 5 5-7-83 select PNUM from parts where QOH = ( select count(SHIPDATE) from supply where supply.PNUM = parts.PNUM and SHIPDATE < 1-1-80) Result PNUM 10 8

The Count Bug (cont.) Parts Supply PNUM QOH 3 6 10 1 8 PNUM QUAN PNUM QUAN SHIPDATE 3 4 7-3-79 2 10-1-78 10 1 6-8-78 8-10-81 8 5 5-7-83 Temp temp (SUPPNUM,CT) = (select PNUM, count(SHIPDATE) from supply where SHIPDATE < 1-1-80) group by PNUM) Suppnum CT 3 2 10 1

The Count Bug (cont.) Parts Temp PNUM QOH 3 6 10 1 8 SUPPNUM CT 3 2 10 SUPPNUM CT 3 2 10 1 Result select PNUM from parts, temp where parts.QOH = temp.CT and temp.PNUM = parts.PNUM PNUM 10

The Count Bug – solution with outer joins X A B Y B C E X Y A null B C E Null R S R=+S

The Count Bug – solution with outer joins temp (SUPPNUM,CT) = (select parts.PNUM, count(SHIPDATE) from parts, supply where SHIPDATE < 1-1-80 and parts.PNUM =+ supply.PNUM group by parts.PNUM) parts.PNUM =+ supply.PNUM (for SHIPDATE < 1-1-80) Parts.PNUM Parts.QOH Supply.PNUM Supply.QUON Supply.SHIPDATE 3 6 4 7-3-79 2 10-1-78 10 1 6-8-78 8 null