Keywords: Subqueries, processing and transformations of

# Subquery processing and transformations

Subqueries are notoriously expensive to evaluate. This section describes some of the transformations that Derby makes internally to reduce the cost of evaluating them.

- Materialization
  Materialization means that a subquery is evaluated only once. There are several types of subqueries that can be materialized.
- Flattening a subquery into a normal join
- Flattening a subquery into an EXISTS join
- Flattening VALUES subqueries
- DISTINCT elimination in IN, ANY, and EXISTS subqueries
- IN/ANY subquery transformation

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