Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 8.

Slides:



Advertisements
Similar presentations
Overview of Query Evaluation (contd.) Chapter 12 Ramakrishnan and Gehrke (Sections )
Advertisements

Query Optimization Reserves Sailors sid=sid bid=100 rating > 5 sname (Simple Nested Loops) Imperative query execution plan: SELECT S.sname FROM Reserves.
CSE544 Database Statistics Tuesday, February 15 th, 2011 Dan Suciu , Winter
Query Optimization CS634 Lecture 12, Mar 12, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Evaluation of Relational Operators CS634 Lecture 11, Mar Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Query Optimization Chapters 14.
Query Optimization Goal: Declarative SQL query
1 Overview of Query Evaluation Chapter Objectives  Preliminaries:  Core query processing techniques  Catalog  Access paths to data  Index matching.
1 Overview of Indexing Chapter 8 – Part II. 1. Introduction to indexing 2. First glimpse at indices and workloads.
1 Relational Query Optimization Module 5, Lecture 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Query Evaluation Chapter 12.
1 Implementation of Relational Operations Module 5, Lecture 1.
Query Rewrite: Predicate Pushdown (through grouping) Select bid, Max(age) From Reserves R, Sailors S Where R.sid=S.sid GroupBy bid Having Max(age) > 40.
1 File Organizations and Indexing Module 4, Lecture 2 “How index-learning turns no student pale Yet holds the eel of science by the tail.” -- Alexander.
Relational Query Optimization (this time we really mean it)
Query Optimization II R&G, Chapters 12, 13, 14 Lecture 9.
CMSC724: Database Management Systems Instructor: Amol Deshpande
Query Optimization 3 Cost Estimation R&G, Chapters 12, 13, 14 Lecture 15.
CS186 Final Review Query Optimization.
1 Overview of Indexing Chapter 8 – Part II. 1. Introduction to indexing 2. First glimpse at indices and workloads.
Overview of Query Optimization v Plan : Tree of R.A. ops, with choice of alg for each op. –Each operator typically implemented using a `pull’ interface:
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8.
Query Optimization, part 2 CS634 Lecture 13, Mar Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Overview of Implementing Relational Operators and Query Evaluation
Introduction to Database Systems1 Relational Query Optimization Query Processing: Topic 2.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Query Evaluation Chapter 12: Overview.
Access Path Selection in a Relational Database Management System Selinger et al.
Query Optimization. overview Histograms A histogram is a data structure maintained by a DBMS to approximate a data distribution Equiwidth vs equidepth.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8 “How index-learning turns no student pale Yet holds.
CPSC 404, Laks V.S. Lakshmanan1 Evaluation of Relational Operations: Other Operations Chapter 14 Ramakrishnan & Gehrke (Sections ; )
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.
Storage and Indexing1 Overview of Storage and Indexing.
1 Relational Query Optimization Chapter Query Blocks: Units of Optimization  An SQL query is parsed into a collection of query blocks :  An SQL.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Implementing Relational Operators and Query Evaluation Chapter 12.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8 “If you don’t find it in the index, look very.
CS4432: Database Systems II Query Processing- Part 3 1.
Introduction to Query Optimization, R. Ramakrishnan and J. Gehrke 1 Introduction to Query Optimization Chapter 13.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Introduction to Query Optimization Chapter 13.
Relational Operator Evaluation. Overview Application Programmer (e.g., business analyst, Data architect) Sophisticated Application Programmer (e.g.,
1 Database Systems ( 資料庫系統 ) December 13, 2004 Chapter 15 By Hao-hua Chu ( 朱浩華 )
CS 440 Database Management Systems Query Optimization 1.
Implementation of Database Systems, Jarek Gryz1 Evaluation of Relational Operations Chapter 12, Part A.
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 4.
Cost Estimation For each plan considered, must estimate cost: –Must estimate cost of each operation in plan tree. Depends on input cardinalities. –Must.
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 8.
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 6.
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 5.
1 Overview of Query Evaluation Chapter Outline  Query Optimization Overview  Algorithm for Relational Operations.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8 Jianping Fan Dept of Computer Science UNC-Charlotte.
Database Applications (15-415) DBMS Internals- Part X Lecture 21, April 3, 2016 Mohammad Hammoud.
CS4432: Database Systems II Query Processing- Part 1 1.
CS 440 Database Management Systems
Database System Architecture and Implementation
CS522 Advanced database Systems
Prepared by : Ankit Patel (226)
Introduction to Query Optimization
Chapter 15 QUERY EXECUTION.
Introduction to Database Systems
Relational Query Optimization
File Organizations and Indexing
File Organizations and Indexing
Database Applications (15-415) DBMS Internals- Part IX Lecture 21, April 1, 2018 Mohammad Hammoud.
Query Optimization.
Relational Query Optimization
Overview of Query Evaluation
Relational Query Optimization
CS222P: Principles of Data Management Notes #13 Set operations, Aggregation, Query Plans Instructor: Chen Li.
Database Applications (15-415) DBMS Internals- Part X Lecture 22, April 3, 2018 Mohammad Hammoud.
CS222: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Presentation transcript:

Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 8

Query Optimization Similar to other optimization Optimize by search Two main factor: Search Space: how many candidates Evaluation function : how to judge which candidate is good Search Space Query Plan

Query Optimization Search Space Enumeration Relational Algebra Equivalences Query rewrite: View rewrite Semantic rewrite Subquery flatterning

Query Optimization Evaluation function: A.K.A cost model Evaluate query plan based on statistical information Assumptions: Independence, Uniform distribution, inclusion assumption Reduction Factor Selectivity Histogram: Equiwidth Equidepth Number of Rows Per Column Distinct Value Per Column Value Distribution Combined Column Value Distribution Available Index... Number of Rows Per Column Distinct Value Per Column Value Distribution Combined Column Value Distribution Available Index...

Query Optimization What if we know both ? Dynamic programming optimization Optimal Substructure C D A B If Q is optimal, all its subquery are optimal

Question 1 (A)

Question 1 (B)

Question 1 (C) A Implies B U A A

Question 2 Equiwidth histogram with 3 buckets 9 distinct value Each bucket has 3 distinct values

Question 3 Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age)

Question 3 (a) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) 20,000 Not Applicable

Question 3 (b) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable 2, ,000

Question 3 (c) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable

Question 3 (d) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable 2, Not Applicable

Question 3 (e) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable

Question 3 (f) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable 2, ,000

Question 3 (g) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable

Question 3 (h) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable