# Package org.modeshape.jcr.query.optimize

This package contains the Optimizer interface, a rule-based optimizer implementation, and library of optimization rules.

See: Description

- Interface Summary
  Interface | Description
  --- | ---
  Optimizer | Interface for an optimizer.
  OptimizerRule | Interface that defines an `Optimizer` rule.

- Class Summary
  Class | Description
  --- | ---
  AddAccessNodes | An `optimizer rule` that inserts an ACCESS above each SOURCE leaf node in a query plan.
  AddJoinConditionColumnsToSources | An `OptimizerRule` that adds any missing columns required by the join conditions to the appropriate join source.
  AddOrderingColumnsToSources | An `OptimizerRule` that adds any missing columns required by the ordering specifications to the SORT node's PROJECT, and to the appropriate access nodes.
  ChooseJoinAlgorithm | An `optimizer rule` that choose the appropriate join algorithm and sets up any prerequisites, based upon the `JoinCondition`.
  CopyCriteria | An `optimizer rule` that copies SELECT nodes that apply to one side of a equi-join condition so that they also apply to the other side fo the equi-join condition.
  PushProjects | This rule attempts to ensure the proper location of `PlanNode.Type.PROJECT` nodes.
  PushSelectCriteria | An `optimizer rule` that attempts to push the criteria nodes in a canonical plan down as far as possible.
  RaiseSelectCriteria | An `optimizer rule` that moves up higher in the plan any SELECT node that appears below a JOIN node and that applies to selectors that are on the other side of the join.
  RaiseVariableName | An `optimizer rule` that moves up higher in the plan any `variable name` property to the node immediately under a `dependent query` node.
  RemoveEmptyAccessNodes | An `optimizer rule` that removes any ACCESS nodes that are known to never return any tuples because of conflicting constraints.
  ReplaceViews | An `optimizer rule` that replaces any SOURCE nodes that happen to be `views`.
  RewriteAsRangeCriteria | An `optimizer rule` that rewrites two `AND-ed` `Constraint`s that constraint a dynamic operand to a range of values as a single `Between` constraint.
  RewriteIdentityJoins | An `optimizer rule` that rewrites JOIN nodes that have `equi-join criteria` where the columns involved in the equi-join are all identity columns (that is, they form a `key` for the table).
  RewritePathAndNameCriteria | An `optimizer rule` that rewrites Constraint trees, moving path-, name-, or depth-oriented criteria to the left-most parts of the constraint tree.
  RewritePseudoColumns | An `optimizer rule` that moves up higher in the plan any `variable name` property to the node immediately under a `dependent query` node.
  RightOuterToLeftOuterJoins | An `optimizer rule` that converts `right outer joins` into `left outer joins`.
  RuleBasedOptimizer | Optimizer implementation that optimizes a query using a stack of rules.

## Package org.modeshape.jcr.query.optimize Description

This package contains the Optimizer interface, a rule-based optimizer implementation, and library of optimization rules. The Optimizer is responsible for evaluating, validating, and manipulating a canonical query plan to produce a more a single optimized query processing plan. The query plan is often changed in situ, although this is not required of the `Optimizer` implementations. A library of existing `OptimizerRule` classes is provided, though it's very easy to add more optimizer rules.

The `RuleBasedOptimizer` is an implementation that optimizes a query using a stack of rules. A new stack is created for each rule, though the rules are required to be immutable and thus often shared and reused. And, the RuleBasedOptimizer is easily subclassed to define a custom stack of rules.

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.