# Transitive closure

The transitive property of numbers states that if A = B and B = C, then A = C.

Derby applies this property to query predicates to add additional predicates to the query in order to give the optimizer more information. This process is called transitive closure. There are two types of transitive closure:

- Transitive closure on join clauses (applied first, if applicable)
- Transitive closure on search clauses

- Transitive closure on join clauses
  When a join statement selects from three or more tables, Derby analyzes any equijoin predicates between simple column references within each query block and adds additional equijoin predicates where possible if they do not currently exist.
- Transitive closure on search clauses
  Derby applies transitive closure on search clauses after transitive closure on join clauses.

Parent topic: Internal language transformations
Related concepts
Predicate transformations
View transformations
Subquery processing and transformations
Outer join transformations
Sort avoidance
Aggregate processing