We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byDeshaun Chafin
Modified over 3 years ago
Algebraic Transformations Page 1 © 2013 Hortonworks HIVE-784: Sub Query in Where or Having clause HIVE-5555: Alt. Join Syntax; Join conditions in the Where Clause
Sub Query transformation Page 2 © 2013 Hortonworks Support for In, Not In, Exists, Not Exists in Where or Having clause But lots of restrictions –Sub Query predicate must be a top level conjunct –Only 1 Sub Query predicate –No Sub Query nesting –Correlation condition must be valid join conditions –And many more: See Spec on HIVE-784; 17 Restrictions so far. Transformation at a high level are: –In/Exists => Left Outer Join –Not In/Exists => Left Outer Join + null check + null count for Not In –Correlation converted to Gby in Sub Query In spite of long list of Restrictions, possibly useful –See HIVE-784 for TPCH Queries Q4, Q15, Q16, Q18 written with SQs –TPCDS Query 45
Some Examples Page 3 © 2013 Hortonworks -- non agg, corr select * from src b where b.key in (select a.key from src a where b.value = a.value and a.key > '9' ) ; -- non agg, non corr select key, count(*) from src group by key having count(*) in (select count(*) from src s1 where s1.key > '9' group by s1.key ) ; -- tpch Q4 select o_orderpriority, count(*) as order_count from orders o where unix_timestamp(o_orderdate, 'yyyy-MM-dd') >= unix_timestamp('1993-07-01', 'yyyy-MM-dd') and unix_timestamp(o_orderdate, 'yyyy-MM-dd') < unix_timestamp('1993-10-01', 'yyyy-MM-dd') and exists ( select * from lineitem where l_orderkey = o.o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority;
Join syntax Page 4 © 2013 Hortonworks I want to use old-style Join syntax: join conditions in Where clause Sub problems: –HIVE-5556: Push Join conditions up Join tree. –So A join B join C on A.x = B.x and A.y = C.y should be handled as: –A join B on A.x = B.x join C on A.y = C.y –Fix holes in handling of Join Tree merging –HIVE-5557: Push ‘qualifying’ predicates from Where Clause up Join Tree –HIVE-5558: support alternate syntax for cross product (allow use of comma).
Introduction to SQL Tuning Brown Bag Three essential concepts.
Chapter 4 Joining Multiple Tables
A Guide to SQL, Seventh Edition. Objectives Use joins to retrieve data from more than one table Use the IN and EXISTS operators to query multiple tables.
Session 3BBK P1 Module05-May-2007 : [‹#›] Date Manipulation.
Query Optimization Reserves Sailors sid=sid bid=100 rating > 5 sname (Simple Nested Loops) Imperative query execution plan: SELECT S.sname FROM Reserves.
Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.
1 Jaql → pipes Unix pipes for the JSON data model Kevin Beyer, Vuk Ercegovac, Eugene Shekita, Jun Rao, Ning Li, Sandeep Tata IBM Almaden Research Center.
Query Optimization CS634 Lecture 12, Mar 12, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Implementation of relational operations
Ι.Β -- Εκτέλεση Ερωτήσεων και ΒελτιστοποίησηΣελίδα 4.40 Κεφάλαιο 9 Επεξεργασία και Βελτιστοποίηση Ερωτήσεων σε Σχεσιακές Βάσεις Δεδομένων.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Query Optimization Chapters 14.
Implementation of Other Relational Algebra Operators, R. Ramakrishnan and J. Gehrke1 Implementation of other Relational Algebra Operators Chapter 12.
Database Management Systems, R. Ramakrishnan and Johannes Gehrke1 Evaluation of Relational Operations: Other Techniques Chapter 12, Part B.
1 Overview of Query Evaluation Chapter Objectives Preliminaries: Core query processing techniques Catalog Access paths to data Index matching.
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.
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.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 8 Advanced SQL.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
ICS (072)Query Processing and Optimization 1 Chapter 15 Algorithms for Query Processing and Optimization ICS 424 Advanced Database Systems Dr.
Query Optimization Overview Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems December 1, 2005 Some slide content derived.
© 2019 SlidePlayer.com Inc. All rights reserved.