Query Optimization Example Source: Query Optimization, Y. E. Ioannidis, ACM Computing Surveys, 28(1), March 1996. Database Tables: Emp (name, age, sal,

Slides:



Advertisements
Similar presentations
Examples of Physical Query Plan Alternatives
Advertisements

Physical Database Design and Tuning R&G - Chapter 20 Although the whole of this life were said to be nothing but a dream and the physical world nothing.
CS 245Notes 71 CS 245: Database System Principles Notes 7: Query Optimization Hector Garcia-Molina.
Copyright © 2011 Ramez Elmasri and Shamkant Navathe Algorithms for SELECT and JOIN Operations (8) Implementing the JOIN Operation: Join (EQUIJOIN, NATURAL.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5 Modified by Donghui Zhang.
6.830/6.814 Lecture 5 Database Internals Continued September 17, 2014.
CS CS4432: Database Systems II Operator Algorithms Chapter 15.
Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 8.
Query Optimization Goal: Declarative SQL query
Query Evaluation. An SQL query and its RA equiv. Employees (sin INT, ename VARCHAR(20), rating INT, age REAL) Maintenances (sin INT, planeId INT, day.
Spring 2003 ECE569 Lecture 06.1 ECE 569 Database System Engineering Spring 2003 Topic VIII: Query Execution and optimization Yanyong Zhang
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
CS 245Notes 71 CS 245: Database System Principles Notes 7: Query Optimization Hector Garcia-Molina.
CS263 Lecture 19 Query Optimisation.  Motivation for Query Optimisation  Phases of Query Processing  Query Trees  RA Transformation Rules  Heuristic.
1 Optimization Recap and examples. 2 Optimization introduction For every SQL expression, there are many possible ways of implementation. The different.
1 Review #1 l Intro stuff –What is a database, 4 parts, 3 users, etc. l Architecture –Data independence –Three levels, two mappings –Jobs of the DBA.
1 Query Optimization. 2 Why Optimize? Given a query of size n and a database of size m, how big can the output of applying the query to the database be?
1 Lecture 22: Query Execution Wednesday, March 2, 2005.
ACS-4902 Ron McFadyen Chapter 15 Algorithms for Query Processing and Optimization.
Query Optimization 3 Cost Estimation R&G, Chapters 12, 13, 14 Lecture 15.
Prof. Ghandeharizadeh1 QUERY PROCESSING (CHAPTER 12)
CS186 Final Review Query Optimization.
Introduction to Database Systems 1 Join Algorithms Query Processing: Lecture 1.
Query Processing & Optimization
1 Query Optimization Vishy Poosala Bell Labs. 2 Outline Introduction Necessary Details –Cost Estimation –Result Size Estimation Standard approach for.
...Looking back Why use a DBMS? How to design a database? How to query a database? How does a DBMS work?
Optimization Exercises. Question 1 How do you think the following query should be computed? What indexes would you suggest to use? SELECT E.ename, D.mgr.
1 Optimization. 2 Why Optimize? Given a query of size n and a database of size m, how big can the output of applying the query to the database be? Example:
Query Processing Presented by Aung S. Win.
Cloud Computing Lecture Column Store – alternative organization for big relational data.
Lecture 11 Main Memory Databases Midterm Review. Time breakdown for Shore DBMS Source: “OLTP Under the Looking Glass”, SIGMOD 2008 Systematically removed.
Practical Database Design and Tuning. Outline  Practical Database Design and Tuning Physical Database Design in Relational Databases An Overview of Database.
1 Revision and Exam Briefing M. Akhtar Ali School of CEIS.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 14 – Join Processing.
CSE 6331 © Leonidas Fegaras System R1 System R Optimizer Read the paper (available at the course web page): G. Selinger, M. Astrahan, D. Chamberlin, R.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
Advanced Databases: Lecture 8 Query Optimization (III) 1 Query Optimization Advanced Databases By Dr. Akhtar Ali.
1 ICS 184: Introduction to Data Management Lecture Note 10 SQL as a Query Language (Cont.)
Query Processing and Optimization
1 ICS 184: Introduction to Data Management Lecture Note 11: Assertions, Triggers, and Index.
Lecture 5 Cost Estimation and Data Access Methods.
6.830 Lecture 6 9/28/2015 Cost Estimation and Indexing.
42 Example Join-- File Information 4 Emp( Fn Char(10), Minit Char, LN Char(20), SSN number(9), Bdate Date, Addr char(40), Sex Char, Salary Number(9,2),
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
CS 440 Database Management Systems Lecture 5: Query Processing 1.
More Optimization Exercises. Block Nested Loops Join Suppose there are B buffer pages Cost: M + ceil (M/(B-2))*N where –M is the number of pages of R.
1 Choosing an Order for Joins. 2 What is the best way to join n relations? SELECT … FROM A, B, C, D WHERE A.x = B.y AND C.z = D.z Hash-Join Sort-JoinIndex-Join.
Physical DB Design Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 8.
Storage Access Paging Buffer Replacement Page Replacement
Module 11: File Structure
CS 540 Database Management Systems
CS 440 Database Management Systems
Secondary Storage Data Retrieval.
Query Optimization Kush Kashyap B.Tech -IT.
Overview of Query Optimization
COST ESTIMATION FOR THE RELATIONAL ALGEBRA OPERATIONS MIT 813 GROUP 15 PRESENTATION.
Access Path Selection in a Relational Database Management System
RELATIONAL ALGEBRA (Chapter 2)
Examples of Physical Query Plan Alternatives
Query Processing B.Ramamurthy Chapter 12 11/27/2018 B.Ramamurthy.
Chapters 15 and 16b: Query Optimization
EXAMPLE Emp table: SS# Name Age Salary dno 1 Joe Mary 20
CS222P: Principles of Data Management Notes #13 Set operations, Aggregation, Query Plans Instructor: Chen Li.
Lecture 23: Query Execution
Integrity Constraints
CPSC-608 Database Systems
Lecture 20: Query Execution
Presentation transcript:

Query Optimization Example Source: Query Optimization, Y. E. Ioannidis, ACM Computing Surveys, 28(1), March Database Tables: Emp (name, age, sal, dno) Dept (dno, dname, floor, budget, mgr, ano) Acnt (ano,t ype, balance, bno) Bank (bno, bname,a ddress) Query Q: select name, floor from emp, dept where emp.dno=dept.dno and sal>100K. System Catalog Information: Table Emp: 20,000 pages, 100,000 tuples, clustering B+tree index on emp.sal (3-levels) selectivity( salary > 100K) = 10 percent Table Dept: 10 pages, 100 tuples, clustering Hash-file on dept.dno (1.2 pages/bucket) Memory Buffer: 3 pages Disk I/O cost: 20 ms/page

Algebraic Tree Transformations

Dynamic Programming: Step 1 – Options at Leafs

Step 2a – Options for Join – nested loop

Step 2 – Options for Join

Semantic Query Optimization Query Q: select name, floor from emp, dept where emp.dno=dept.dno And job = “Sr. Programmer” Integrity Constraint: assert sal-constraint on emp: sal>100K where job = “Sr. Programmer” Query Q’: select name, floor from emp, dept where emp.dno=dept.dno and job = “Sr. Programmer” and sal>100K. System Catalog Information: Table Emp: 20,000 pages, 100,000 tuples, clustering B+tree index on emp.sal (3-levels) selectivity( salary > 100K) = 10 percent Table Dept: 10 pages, 100 tuples, clustering Hash-file on dept.dno (1.2 pages/bucket) Memory Buffer: 3 pages Disk I/O cost: 20 ms/page Q? Compare queries Q and Q’ on Query Result Efficiency of query plans