Query Rewrite Starburst Model (IBM). DB2 Query Optimizer (Starburst) Parsing and Semantic Checking Query Rewrite Plan Optimization Query Evaluation System.

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.
Query processing and optimization. Advanced DatabasesQuery processing and optimization2 Definitions Query processing –translation of query into low-level.
DB performance tuning using indexes Section 8.5 and Chapters 20 (Raghu)
CS263 Lecture 19 Query Optimisation.  Motivation for Query Optimisation  Phases of Query Processing  Query Trees  RA Transformation Rules  Heuristic.
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.
ICS (072)Query Processing and Optimization 1 Chapter 15 Algorithms for Query Processing and Optimization ICS 424 Advanced Database Systems Dr.
16.5 Introduction to Cost- based plan selection Amith KC Student Id: 109.
CS 584. Discrete Optimization Problems A discrete optimization problem can be expressed as (S, f) S is the set of all feasible solutions f is the cost.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
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.
1 Advance Computer Architecture CSE 8383 Ranya Alawadhi.
CMSC424: Database Design Instructor: Amol Deshpande
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
Query Processing. Steps in Query Processing Validate and translate the query –Good syntax. –All referenced relations exist. –Translate the SQL to relational.
Dive into the Query Optimizer Dive into the Query Optimizer: Undocumented Insight Benjamin Nevarez Blog: benjaminnevarez.com
RESTORE IMPLEMENTATION as an extension to pig Vijay S.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
SPARQL Query Graph Model (How to improve query evaluation?) Ralf Heese and Olaf Hartig Humboldt-Universität zu Berlin.
CPS216: Data-Intensive Computing Systems Introduction to Query Processing Shivnath Babu.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Query Processing (based on notes by C. Faloutsos at CMU)
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
Query optimization in distributed database systems.
Module 4 Database SQL Tuning Section 3 Application Performance.
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.
WEEK 6 Day 2. Progress report Thursday the 11 th.
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.
Inside Query Processor Sort Dmitry Pilugin SQL Server Developer, MVP (RU) (EN)
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.
Closing the Query Processing Loop in Oracle 11g Allison Lee, Mohamed Zait.
CHAPTER 19 Query Optimization. CHAPTER 19 Query Optimization.
Chapter 14: Query Optimization
Tuning Transact-SQL Queries
Prepared by : Ankit Patel (226)
Chapter 12: Query Processing
Chapter 15 QUERY EXECUTION.
Query Rewrite Starburst Model (IBM).
Practical Database Design and Tuning
Outline Introduction Background Distributed DBMS Architecture
Query Rewrite Starburst Model (IBM).
Extensible/Rule Based Query Rewrite Optimization in Starburst
Query Rewrite Starburst Model (IBM).
CS222P: Principles of Data Management Notes #13 Set operations, Aggregation, Query Plans Instructor: Chen Li.
Query Optimization.
Query Processing.
Presentation transcript:

Query Rewrite Starburst Model (IBM)

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

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 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’ SELECT itm.itmn, itpv.vendn FROM itm, itpv WHERE itm.itemn = itpv.itemn 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’ ) Speedup: 8 times SELECT DISTINCT itemn FROM wor, itl WHERE empno = ‘EMPN1279’ entry_time = ‘9773’ AND wkctr = ‘WK195’ ) AND itl.itmn = wor.itemn

The Count Bug 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 select PNUM from parts where QOH = ( select count(SHIPDATE) from supply where supply.PNUM = parts.PNUM and SHIPDATE < )

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

The Count Bug (cont.) PNUMQOH PNUMQUANSHIPDATE select PNUM from parts where QOH = ( select count(SHIPDATE) from supply where supply.PNUM = parts.PNUM and SHIPDATE < ) SupplyParts PNUM 10 8 Result

The Count Bug (cont.) PNUMQOH PNUMQUANSHIPDATE SupplyParts Temp temp (SUPPNUM,CT) = ( select PNUM, count(SHIPDATE) from supply where SHIPDATE < ) group by PNUM) SuppnumCT

The Count Bug (cont.) PNUMQOH Parts Temp SUPPNUMCT select PNUM from parts, temp where parts.QOH = temp.CT and temp.PNUM = parts.PNUM Result PNUM 10

The Count Bug – solution with outer joins X A B Y B C E RSR=+S XY Anull BB C E

The Count Bug – solution with outer joins temp (SUPPNUM,CT) = ( select parts.PNUM, count(SHIPDATE) from parts, supply where SHIPDATE < and parts.PNUM =+ supply.PNUM group by parts.PNUM) Parts.PNUMParts.QOHSupply.PNUMSupply.QUONSupply.SHIPDATE null parts.PNUM =+ supply.PNUM (for SHIPDATE < )