Finish Two Pass Query Algorithms - Query Parsing and Optimization




CS157b

Chris Pollett

Mar 4, 2020

Outline

Introduction

Partitioning Relations by Hashing

Hashed based Duplicate Elimination

In-Class Exercise

Hash-Based Algorithm for Grouping and Aggregation

Two Pass Group By Hash Example

Two Pass Group By Hash Example

Hash based and Unions, Intersections, etc

Hash-Join

Index-based Selection

Index-based Join

Parsing Queries

Syntax Analysis and Parse Trees

A Grammar for a Simple Subset of SQL

Example

SELECT name
FROM MovieStar
WHERE birthdate LIKE '%1960'

Might yield parse tree:

Example Parse Tree

The Preprocessor

Algebraic Laws For Improving Query Plans

Commutative and Associative Laws

Laws Involving Selection

Pushing Selections

Laws Involving Projection

Laws for Joins and Products

From Parse Trees to Logical Query Plans