Arranging the Join Order: the Wong-Youssefi algorithm (INGRES)

Slides:



Advertisements
Similar presentations
Examples of Physical Query Plan Alternatives
Advertisements

Query Folding Xiaolei Qian Presented by Ram Kumar Vangala.
1 Relational Query Optimization Module 5, Lecture 2.
Murali Mani The Relational Model. Murali Mani Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still.
Sample queries Practice in using Oracle SQL (1 of 2)
CS186 Final Review Query Optimization.
CS34311 The Entity- Relationship Model Part II.. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Query Optimization R&G, Chapter 15 Lecture 16. Administrivia Homework 3 available today –Written exercise; will be posted on class website –Due date:
Data Manipulation 11 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and other programming.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Query Evaluation Chapter 12: Overview.
Join Synopses for Approximate Query Answering Swarup Achrya Philip B. Gibbons Viswanath Poosala Sridhar Ramaswamy Presented by Bhushan Pachpande.
Query Processing Notes. Query Processing The query processor turns user queries and data modification commands into a query plan - a sequence of operations.
Algebra1 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and Relational Algebra expressions.
1 Computing Full Disjunctions Yaron Kanza Yehoshua Sagiv The Selim and Rachel Benin School of Engineering and Computer Science The Hebrew University of.
Database Techniek – Query Optimization Database Techniek Query Optimization (chapter 14)
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Introduction to Query Optimization Chapter 13.
Log Truck Scheduling Problem
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh Part-2.
CSCI Query Processing1 QUERY PROCESSING & OPTIMIZATION Dr. Awad Khalil Computer Science Department AUC.
QUERY CONSTRUCTION CS1100: Data, Databases, and Queries CS1100Microsoft Access1.
CS34311 Translating ER Schema to Relational Model.
Database Applications (15-415) DBMS Internals- Part IX Lecture 20, March 31, 2016 Mohammad Hammoud.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Basic SQL Queries.
Query Optimization. overview Application Programmer (e.g., business analyst, Data architect) Sophisticated Application Programmer (e.g., SAP admin) DBA,
SQL Exercises. 1) Names of suppliers. Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)
Structured Query Language IV Asma Ahmad (C. J. Date) Database Systems.
Database Applications (15-415) DBMS Internals- Part VIII Lecture 17, Oct 30, 2016 Mohammad Hammoud.
Database Systems (資料庫系統)
STRUCTURE OF PRESENTATION :
Relational Database Design by ER- and EER-to- Relational Mapping
Some TPC-H queries on Teradata and PostgreSQL
Database System Implementation CSE 507
Introduction to the database systems (1)
UNIT 11 Query Optimization
Day 4 - Simple Queries & More on Tables
Multiplication table. x
CS222P: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Translating ER Schema to Relational Model
CSE373: Data Structures & Algorithms Lecture 15: B-Trees
Query Sampling in DB2.
Referential Integrity
Optimizing Queries Using Materialized Views
Examples of Physical Query Plan Alternatives
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Relational Databases Relational Algebra (1) Select, project, join.
Query Sampling in DB2.
Referential Integrity
SQL: The Query Language Part 1
Φροντιστήριο SQL (από το βιβλίο του Date)
Database Applications (15-415) DBMS Internals- Part IX Lecture 21, April 1, 2018 Mohammad Hammoud.
Dealing with Uniqueness Constraint in Query Optimization
April 27th – Cost Estimation
Chapter 5 Advanced Data Modeling
Unit 7 Normalization (表格正規化).
Advance Database Systems
Normalization cs3431.
Overview of Query Evaluation
Instructor: Mohamed Eltabakh
Relational Algebra Friday, 11/14/2003.
Semantic Query Optimization
Relational Database Design
Relational Query Optimization
STRUCTURE OF PRESENTATION :
실습 4주차.
Joins and other advanced Queries
Question 1: Basic Concepts (45 %)
CS222: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
File and data base concepts
SQL.
Presentation transcript:

Arranging the Join Order: the Wong-Youssefi algorithm (INGRES) Sample TPC-H Schema Nation(NationKey, NName) Customer(CustKey, CName, NationKey) Order(OrderKey, CustKey, Status) Lineitem(OrderKey, PartKey, Quantity) Product(SuppKey, PartKey, PName) Supplier(SuppKey, SName) Find the names of suppliers that sell a product that appears in a line item of an order made by a customer who is in Canada SELECT SName FROM Nation, Customer, Order, LineItem, Product, Supplier WHERE Nation.NationKey = Cuctomer.NationKey AND Customer.CustKey = Order.CustKey AND Order.OrderKey=LineItem.OrderKey AND LineItem.PartKey= Product.Partkey AND Product.Suppkey = Supplier.SuppKey AND NName = “Canada”

Challenges with Large Natural Join Expressions For simplicity, assume that in the query All joins are natural whenever two tables of the FROM clause have common attributes we join on them Consider Right-Index only πSName RI RI One possible order RI RI RI σNName=“Canada” Index Nation Customer Order LineItem Product Supplier

Multiple Possible Orders πSName RI RI RI RI RI σNName=“Canada” Nation Customer Order LineItem Product Supplier

Wong-Yussefi algorithm assumptions and objectives Assumption 1 (weak): Indexes on all join attributes (keys and foreign keys) Assumption 2 (strong): At least one selection creates a small relation A join with a small relation results in a small relation Objective: Create sequence of index-based joins such that all intermediate results are small

Hypergraphs Customer Nation LineItem Order Supplier Product CName CustKey Nation NationKey NName LineItem Order Quantity PartKey Status OrderKey Supplier SName SuppKey PName Product relation hyperedges two hyperedges for same relation are possible each node is an attribute can extend for non-natural equality joins by merging nodes

Small Relations/Hypergraph Reduction “Nation” is small because it has the equality selection NName = “Canada” Customer CName CustKey Nation NationKey NName NationKey NName LineItem Order Quantity PartKey Status OrderKey Supplier SName SuppKey PName Product σNName=“Canada” Index Pick a small relation (and its conditions) to start the plan Nation

σNName=“Canada” Customer Nation LineItem Order Supplier Product Remove small relation (hypergraph reduction) and color as “small” any relation that joins with the removed “small” relation CName CustKey Nation NationKey NName NationKey NName LineItem Order Quantity PartKey Status OrderKey Supplier SName SuppKey PName Product RI Pick a small relation (and its conditions if any) and join it with the small relation that has been reduced σNName=“Canada” Index Customer Nation

After a bunch of steps… πSName σNName=“Canada” Nation Customer Order RI RI RI RI RI σNName=“Canada” Index Nation Customer Order LineItem Product Supplier

Multiple Instances of Each Relation SELECT S.SName FROM Nation, Customer, Order, LineItem L, Product P, Supplier S, LineItem LE, Product PE, Supplier Enron WHERE Nation.NationKey = Cuctomer.NationKey AND Customer.CustKey = Order.CustKey AND Order.OrderKey=L.OrderKey AND L.PartKey= P.Partkey AND P.Suppkey = S.SuppKey AND Order.OrderKey=LE.OrderKey AND LE.PartKey= PE.Partkey AND PE.Suppkey = Enron.SuppKey AND Enron.Sname = “Enron” AND NName = “Cayman” Find the names of suppliers whose products appear in an order made by a customer who is in Cayman Islands and an Enron product appears in the same order

Multiple Instances of Each Relation Customer CName CustKey Nation NationKey NName LineItem L Order Quantity PartKey Quantity Status OrderKey Supplier S SName SuppKey PName Product P Supplier Enron SName SuppKey PName PartKey LineItem LE Product PE

Multiple choices are possible Customer CName CustKey Nation NationKey NName LineItem L Order Quantity PartKey Quantity Status OrderKey Supplier S SName SuppKey PName Product P Supplier Enron SName SuppKey PName PartKey LineItem LE Product PE

Customer Nation LineItem L Order Supplier S Product P Supplier Enron CName CustKey Nation NationKey NName LineItem L Order Quantity PartKey Quantity Status OrderKey Supplier S SName SuppKey PName Product P Supplier Enron SName SuppKey PName PartKey LineItem LE Product PE

Customer Nation LineItem L Order Supplier S Product P Supplier Enron CName CustKey Nation NationKey NName LineItem L Order Quantity PartKey Quantity Status OrderKey Supplier S SName SuppKey PName Product P Supplier Enron SName SuppKey PName PartKey LineItem LE Product PE

σSName=“Enron” σNName=“Cayman” LineItem Product Supplier PE Enron LE RI RI RI LineItem Product Supplier RI RI RI RI σSName=“Enron” Index σNName=“Cayman” Index PE Enron LE Nation Customer Order