Relational Rewrite Laws and Filter Placement

Push a predicate across a join only when the referenced fields and row-preservation rules justify it.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Independent inner-join inputs can be filtered before pairing
  2. An outer join deliberately creates unmatched rows

Independent inner-join inputs can be filtered before pairing

For an inner join, a deterministic predicate mentioning only the left relation can usually be applied to that relation before joining. Each pair survives exactly when its left member passes. This reduces work without changing multiplicity under usual bag filtering. Additional observable effects or error behavior can restrict transformations outside pure relational semantics.

An outer join deliberately creates unmatched rows

If a left outer join produces an unmatched row, right-side attributes are missing. Filtering on right-side equality after the join removes that row because the predicate is unknown. Applying that filter only inside the right input leaves the left row eligible to appear as unmatched. Those plans therefore differ. Three-valued logic supplies the evaluation, and query plan analysis helps locate the filter that was actually executed.[1][2]

References

  1. CMU 15-445/645, Introduction to Database Systems: Lectures ↩
  2. PostgreSQL Global Development Group, PostgreSQL Documentation ↩