Class RemoveSubPlansWithEmptyResults

java.lang.Object
se.liu.ida.hefquin.engine.queryproc.impl.loptimizer.heuristics.RemoveSubPlansWithEmptyResults
All Implemented Interfaces:
HeuristicForLogicalOptimization

public class RemoveSubPlansWithEmptyResults extends Object implements HeuristicForLogicalOptimization
Removes every subplan that is guaranteed to produce an empty result according to the cardinality estimate that is determined for it. In particular, a subplan is removed if it has a cardinality estimate of 0 with the quality score being QueryPlanProperty.Quality.ACCURATE. The subplans are removed in a top-down manner (i.e., trying to remove bigger subplans first).

The heuristic performs a recursive traversal of the logical plan and simplifies the plan based on emptiness information:

  • If the overall plan itself is provably empty, it is replaced by LogicalPlanWithoutResult.
  • For union and multiway union operators, empty subplans are removed. If exactly one subplan remains, the union operator is removed and replaced by that subplan.
  • For left join operators, if the right subplan is empty, the left join is removed and replaced by its left subplan.
  • For all other operators, empty subplans are not removed individually. Instead, emptiness is propagated via cardinality estimates, allowing higher-level simplifications when possible.
The heuristic relies on precomputed cardinality estimates provided by the CardinalityEstimator.