QueryRewriting: 1 Query Rewriting (for Query “Optimization”) Main Strategy: Make intermediate results small by applying selection and projection early.

Slides:



Advertisements
Similar presentations
COMP 5138 Relational Database Management Systems Semester 2, 2007 Lecture 5A Relational Algebra.
Advertisements

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.
CS CS4432: Database Systems II Logical Plan Rewriting.
Chapter Secondary Storage Rough Speed Differentials –nanoseconds: retrieve data in main memory –microseconds: retrieve from disk cache or under a.
NestedRelations: 1 Nested Relations Flat schemas often have replicated data values in their relations. Nested schemas allow us to collapse some of these.
Chapter Design Objectives Obtain the theoretically “best” design (normalize) –Remove redundancy and update anomalies –Remove nulls –Minimize the.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
XNF: 1 XML and NNF A Standard Form for XML Documents (XNF) Properties –As few hierarchical trees as possible –No redundant data values in any tree Method.
Chapter Abstraction Concrete: directly executable/storable Abstract: not directly executable/storable –automatic translation (as good as executable/storable)
The Query Compiler Section 16.3 DATABASE SYSTEMS – The Complete Book Presented By:Under the supervision of: Deepti KunduDr. T.Y.Lin.
FDImplication: 1 Functional Dependencies (FDs) Let r(R) be a relation and let t  r, then the restriction of t to X  R, written t[X], is the projection.
Chapter Relational Calculus Queries are open predicate-calculus formulas General form: { | F(x 1, …, x n ) } –Standard set-builder notation (i.e.
FileOrg: 1 Secondary Storage Rough Speed Differentials –nanoseconds: retrieve data in main memory –microseconds: retrieve from under a read head –milliseconds:
OSM—Normalize Then Map. ER Model Instance Type  RackRate Room Date  Guest Rate Discount Date  Discount Rate = (1 – Discount/100)  RackRate includes.
Chapter Nested Schemes Flat schemes often have replicated data values. Nested schemes allow us to collapse some of these replicated data values.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter Specification Detailed and precise proposal for a system Provides the technical basis for a contract Typically increases understanding and.
XNF-1 XML and NNF A Standard Form for XML Documents (XNF) Properties –As few hierarchical trees as possible –No redundant data values in any tree Method.
CostEst: 1 Cost Estimation Based on: –operations –file and record sizes –file structures –block layout on disk –caching scheme (in our simplified world,
View Processing & Update. View Processing create view PresSuite as select * from Room where NrBeds = 2 select * from PresSuite p natural join Reservation.
Query Optimization. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
CS 4432logical query rewriting - lecture 151 CS4432: Database Systems II Lecture #15 Logical Query Rewriting Professor Elke A. Rundensteiner.
Create, Insert, Delete, Update. Create Create database Create table Create index – Primary – Secondary.
CostAnalysis: 1 Cost Analysis Rule-of-Thumb Guidelines As a guide, consider denormalizing if: –redundancy is minimal and update anomalies are not expected.
Chapter 19 Query Processing and Optimization
Chapter Implementation Faithful translation of a design into a target environment Design should be free of target-environment dependencies Should.
Design Algorithm Essentials 1.Combine functional edges with the same tail object set(s) into a scheme. (The tail object set(s) and any others in a 1-1.
©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.
PRE-ALGEBRA. Lesson 4-7 Warm-Up PRE-ALGEBRA How do you multiply numbers with the same base? How do you multiply powers in algebraic expressions? Rule:
CS 255: Database System Principles slides: From Parse Trees to Logical Query Plans By:- Arunesh Joshi Id:
Overview of Query Processing
Query Optimization (CB Chapter ) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: An Application Oriented.
Optimization of Relational Algebra Expressions Database I.
Notes Over 8.4 Rewriting Logarithmic Equations Rewrite the equation in exponential form.
Dive into the Query Optimizer Dive into the Query Optimizer: Undocumented Insight Benjamin Nevarez Blog: benjaminnevarez.com
Query Rewrite Starburst Model (IBM). DB2 Query Optimizer (Starburst) Parsing and Semantic Checking Query Rewrite Plan Optimization Query Evaluation System.
Query Processing Bayu Adhi Tama, MTI. 1 ownerNoclient © Pearson Education Limited 1995, 2005.
2-2 HW = Pg #12-32e, 33-38, 44-50e, 62-78e.
2-2 HW = Pg #12-50 e, HW Continued.
Lesson 2-2 Example Use the Commutative and/or Associative Properties to find the sum mentally Step 1 Look for two numbers whose sum is.
More Multiplication Properties of Exponents
Chapter 18 Query Processing. 2 Chapter - Objectives u Objectives of query processing and optimization. u Static versus dynamic query optimization. u How.
§ 1.6 Properties of Integral Exponents.
Multiplication of Exponential Expressions with the Same Base Evaluate each expression, and compare the results obtained in the first column with the corresponding.
Query Processing – Query Trees. Evaluation of SQL Conceptual order of evaluation – Cartesian product of all tables in from clause – Rows not satisfying.
RelAlg: 1 Relational Algebra An Algebra is a pair: (set of values, set of operations) Note that an algebra is the same idea as an ADT Relational Algebra:
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
CSCI Query Processing1 QUERY PROCESSING & OPTIMIZATION Dr. Awad Khalil Computer Science Department AUC.
SQL: 1 SQL Correspondence with Relational Algebra select A from r where B = 1 Assume r(AB) and s(BC). select B from r except select B from s select A as.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Introduction to Query Processing (1) Query optimization: The process of choosing a suitable execution.
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 13 Query Optimization Yonsei University 1 st Semester, 2015 Sanghyun Park.
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
Unit 2 Day 5. Do now Fill in the blanks: is read as “___________________________” The 4 th root can be rewritten as the ________ power. If an expression.
Query Processing and Query Optimization Database System Implementation CSE 507 Slides adapted from Silberschatz, Korth and Sudarshan Database System Concepts.
Query Optimization Heuristic Optimization
Query Optimization Phases of query processing
Basic Block Optimizations
Global optimizations.
Relational Algebra : #I
Implicit Differentiation
Multiplication Properties of Exponents
ALGEBRA I - SECTION 7-2 (Multiplying Powers With the Same Base)
Query Optimization.
Unit 4. Day 6..
Translating Imperative Code into SQL
Basic Block Optimizations
Presentation transcript:

QueryRewriting: 1 Query Rewriting (for Query “Optimization”) Main Strategy: Make intermediate results small by applying selection and projection early. Additional Strategies: Remove unnecessary operations, execute common subexpressions only once, re-order joins to generate smaller intermediate results, …

QueryRewriting: 2 Rewriting Rules 1 & 2 1.  X e = e Note: the scheme of e is X.  RoomNr, Name, NrBeds, Cost r = r 2.  X  f e =  X  f  XY e Note: f mentions the attrs. of Y.  RoomNr, Name  Cost > 75 r =  RoomNr, Name  Cost > 75  RoomNr, Name, Cost r

QueryRewriting: 3 Rewriting Rules 3 & 4 3.  f (e 1 |  | e 2 ) =  f1 (  f2 e 1 |  |  f3 e 2 ) Note: f = f1  f2  f3; each pertains to its respective expression.  ArrivalDate = 15 May  City = Boston (g |  | s) =  City = Boston g |  |  ArrivalDate = 15 May s 4.  X (e 1 |  | e 2 ) =  X (  X 1 Y e 1 |  |  X2Y e 2 ) Note: X1 = X  scheme(e 1 ), X2 = X  scheme(e 2 ), and Y = (scheme(e 1 )  scheme(e 2 )) – X.  RoomNr (r |  | g) =  RoomNr (  RoomNr, Name r |  |  Name g)

QueryRewriting: 4 Rewriting Rules 5 & 6 5.  X  Y e =  X e  Name  RoomNr, Name r =  Name r 6.  f1  f2 e =  f1  f2 e  NrBeds = 2  Cost = 80 r =  NrBeds = 2  Cost = 80 r

QueryRewriting: 5 Rewriting Rules 7, 8 & 9 Natural join (|  |) is (7) commutative, (8) associative, and (9) idempotent. (r |  | (g |  | s)) |  | r = 8 r |  | g |  | s |  | r = 7 r |  | r |  | g |  | s = 9 r |  | g |  | s

QueryRewriting: 6 Query Rewriting – Example  Name, StreetNr, City  ArrivalDate = 10 May  NrBeds = 2 (r |  | g |  | s) = 6,8,3  Name, StreetNr, City (  NrBeds = 2 r |  | g |  |  ArrivalDate = 10 May s) = 8,4  Name, StreetNr, City (  RoomNr, Name  NrBeds = 2 r |  |  GuestNr, Name, StreetNr, City g |  |  GuestNr, RoomNr  ArrivalDate = 10 May s) = 1  Name, StreetNr, City (  RoomNr, Name  NrBeds = 2 r |  | g |  |  GuestNr, RoomNr  ArrivalDate = 10 May s)