Class FilterEvaluationOrderEstimator

java.lang.Object
org.elasticsearch.xpack.esql.datasources.FilterEvaluationOrderEstimator

public final class FilterEvaluationOrderEstimator extends Object
Reorders filter conjuncts by estimated selectivity and cost using column statistics from source metadata. Most selective predicates (those eliminating the most rows) are placed first so that downstream readers can skip data earlier.

Scoring:

  • Primary: estimated selectivity from min/max range width vs predicate value (lower = more selective = evaluated first)
  • Secondary: column size_bytes — smaller column is cheaper to evaluate
  • Fallback: original order preserved for predicates without statistics
  • Method Details

    • orderByEstimatedCost

      public static List<Expression> orderByEstimatedCost(List<Expression> conjuncts, SplitStats stats)
      Returns the conjuncts reordered so the most selective (cheapest) predicates come first. If stats are null, contain a single predicate, or all conjuncts score equally, returns the original list unchanged.