Cost Based Plan Selection




CS157b

Chris Pollett

Mar 16, 2020

Outline

Estimating Costs of Operations

What to select for each plan we generate

  1. An order and grouping on the associative and commutative operations like join, unions, and intersections.
  2. An algorithm for each operator in the logical plan. For example, we need to choose between nested-loop join and hash-join.
  3. Additional operators - scanning, sorting, etc which are needed for the physical plan but are not present in the logical plan.
  4. The way in which arguments are passed from one operator to the next. (By intermediate results or by pipelining).

Estimating Sizes of Intermediate Relations

Estimating the Size of a Projection

Estimating the Size of a Selection

Quiz

Which of the following statements is true?

  1. Disk-based sorting is typical done using Quicksort.
  2. There are example relations `R, S` such that a two pass computation of `R cap S` cannot be done if `B(R) + B(S) < M^3`.
  3. Two pass, hash-based, duplicate elimination algorithm makes use of a partition by hash step.

Estimating the Size of a Join

Natural Joins with Multiple Join Attributes

Joins of Many Relations