planner

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Optimize

func Optimize(s *stream.Stream, tx *database.Transaction, params []expr.Param) (*stream.Stream, error)

Optimize takes a tree, applies a list of optimization rules and returns an optimized tree. Depending on the rule, the tree may be modified in place or replaced by a new one.

func PrecalculateExprRule

func PrecalculateExprRule(s *stream.Stream, _ *database.Transaction, params []expr.Param) (*stream.Stream, error)

PrecalculateExprRule evaluates any constant sub-expression that can be evaluated before running the query and replaces it by the result of the evaluation. The result of constant sub-expressions, like "3 + 4", is always the same and thus can be precalculated. Examples:

3 + 4 --> 7
3 + 1 > 10 - a --> 4 > 10 - a

func RemoveUnnecessaryDistinctNodeRule

func RemoveUnnecessaryDistinctNodeRule(s *stream.Stream, tx *database.Transaction, _ []expr.Param) (*stream.Stream, error)

RemoveUnnecessaryDistinctNodeRule removes any Dedup nodes where projection is already unique.

func RemoveUnnecessaryFilterNodesRule

func RemoveUnnecessaryFilterNodesRule(s *stream.Stream, _ *database.Transaction, _ []expr.Param) (*stream.Stream, error)

RemoveUnnecessaryFilterNodesRule removes any filter node whose condition is a constant expression that evaluates to a truthy value. if it evaluates to a falsy value, it considers that the tree will not stream any document, so it returns an empty tree.

func RemoveUnnecessaryProjection

func RemoveUnnecessaryProjection(s *stream.Stream, _ *database.Transaction, _ []expr.Param) (*stream.Stream, error)

RemoveUnnecessaryProjection removes any project node whose expression is a wildcard only.

func SplitANDConditionRule

func SplitANDConditionRule(s *stream.Stream, _ *database.Transaction, _ []expr.Param) (*stream.Stream, error)

SplitANDConditionRule splits any filter node whose condition is one or more AND operators into one or more filter nodes. The condition won't be split if the expression tree contains an OR operation. Example:

this:
  filter(a > 2 AND b != 3 AND c < 2)
becomes this:
  filter(a > 2)
  filter(b != 3)
  filter(c < 2)

func UseIndexBasedOnFilterNodeRule

func UseIndexBasedOnFilterNodeRule(s *stream.Stream, tx *database.Transaction, params []expr.Param) (*stream.Stream, error)

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.

TODO(asdine): add support for ORDER BY TODO(jh): clarify cost code in composite indexes case

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL