# Functions

Optimize takes a tree, applies a list of optimization rules and returns an optimized tree.
PrecalculateExprRule evaluates any constant sub-expression that can be evaluated before running the query and replaces it by the result of the evaluation.
RemoveUnnecessaryDistinctNodeRule removes any Dedup nodes where projection is already unique.
RemoveUnnecessaryFilterNodesRule removes any filter node whose condition is a constant expression that evaluates to a truthy value.
RemoveUnnecessaryProjection removes any project node whose expression is a wildcard only.
SplitANDConditionRule splits any filter node whose condition is one or more AND operators into one or more filter nodes.
UseIndexBasedOnFilterNodeRule scans the tree for filter nodes whose conditions are operators that satisfies the following criterias: - is a comparison operator - one of its operands is a path expression that is indexed - the other operand is a literal value or a parameter If one or many are found, it will replace the input node by an indexInputNode using this index, removing the now irrelevant filter nodes.