More Query Optimization




CS257

Chris Pollett

Oct 28, 2020

Outline

Physical Query Plan Operators

SELECT title, birthdate 
FROM MovieStar, StarsIn 
WHERE year =1996 AND gender='F' AND starName = 'Starlet'
Expression Tree

Seeing the Physical Query Plan

In-Class Exercise

Model of Computation for Physical Operators

Parameters for Measuring Cost

I/O Cost for Scan Operators

Aside - Sorting in Secondary Storage

Bottom up Merge Sort

Two Phase Multiway Merge-Sort (TPMMS)

N-Way Merge sort

Phase I Example

Phase II

Phase II -cont'd (finish sorting in secondary storage aside)

How much more efficient is this last idea than just merging two blocks?

Iterators for Implementing Physical Operators

One Pass Algorithms -- Tuple at a Time Operations

One-Pass Algorithms for Unary, Full-Relation Operations

One Pass Algorithms for Binary Operations

Nested Loop Joins

More Nested Loop Join

Two Pass Algorithms Based On Sorting

Duplicate Elimination using Sorting

Given `R` we sort `R` and output distinct values.

Sort Based Duplicate Elimination

Grouping and Aggregation using Sorting

Map Reduce and Sorting

Observation on Map Reduce and Sorting