|< < 24 > >|

Rearranging Relational Algebra Expressions

Can the select be done before the join?

  • Yes.
  • In general, this can be done for predicates that refer to columns from one input to the join. Which is extremely common.
  • "Pushing the select below the join" is a very important query optimization.
  • Query optimization involves discovering rearrangements like this, estimating the cost of each, and picking the cheapest alternative.

A faster version of the query

What are the titles of albums by The Detroit Cobras?

Original:

project( select( join(Artist, Album), name == 'The Detroit Cobras') [title])

Rewritten:

project( join( select(Artist, name == 'The Detroit Cobras'), Album), [title])

|< < 24 > >|