@Immutable public class PushSelectCriteria extends Object implements OptimizerRule
optimizer rule
that attempts to push the criteria nodes in a canonical plan down as far as possible.
For example, here is a single-access plan before:
... | PROJECT with the list of columns being SELECTed | SELECT1 | One or more SELECT plan nodes that each have SELECT2 a single non-join constraint that are then all AND-ed | together SELECTn | ACCESS | SOURCEAnd after:
... | ACCESS | PROJECT with the list of columns being SELECTed | SELECT1 | One or more SELECT plan nodes that each have SELECT2 a single non-join constraint that are then all AND-ed | together SELECTn | SOURCEHere is another case, where multiple SELECT nodes above a simple JOIN and where each SELECT node applies to one or more of the SOURCE nodes (via the named selectors). Each SELECT node that applies to a single selector will get pushed toward that source, but will have the same order relative to other SELECT nodes also pushed toward that SOURCE. However, this rules does not push SELECT nodes that apply to multiple selectors.
Before:
... | PROJECT ('s1','s2') with the list of columns being SELECTed (from 's1' and 's2' selectors) | SELECT1 ('s1') | One or more SELECT plan nodes that each have SELECT2 ('s2') a single non-join constraint that are then all AND-ed | together, and that each have the selector(s) they apply to SELECT3 ('s1','s2') | SELECT4 ('s1') | JOIN ('s1','s2') / \ / \ ACCESS ACCESS ('s1') ('s2') | | PROJECT PROJECT ('s1') ('s2') | | SOURCE SOURCE ('s1') ('s2')And after:
... | PROJECT ('s1','s2') with the list of columns being SELECTed (from 's1' and 's2' selectors) | SELECT3 ('s1','s2') Any SELECT plan nodes that apply to multiple selectors are left above | the ACCESS nodes. JOIN ('s1','s2') / \ / \ ACCESS ACCESS ('s1') ('s2') | | PROJECT PROJECT ('s1') ('s2') | | SELECT1 SELECT2 ('s1') ('s2') | | SELECT4 SOURCE ('s1') ('s2') | SOURCE ('s1')
Also, any SELECT that applies to one side of an equi-join will be applied to both sides of the JOIN.
Modifier and Type | Field and Description |
---|---|
static PushSelectCriteria |
INSTANCE |
Constructor and Description |
---|
PushSelectCriteria() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
atBoundary(PlanNode criteriaNode,
PlanNode originatingNode)
Determine whether all of the nodes between the criteria node and its originating node are criteria (SELECT) nodes.
|
PlanNode |
execute(QueryContext context,
PlanNode plan,
LinkedList<OptimizerRule> ruleStack)
Optimize the supplied plan using the supplied context, hints, and yet-to-be-run rules.
|
protected PlanNode |
findBestChildForCriteria(PlanNode criteriaNode,
PlanNode originatingNode) |
protected PlanNode |
findOriginatingNode(PlanNode criteriaNode,
List<PlanNode> originatingNodes)
Find the first node that has all of the same
selectors as the supplied criteria. |
protected boolean |
pushDownJoinCriteria(PlanNode criteriaNode,
PlanNode joinNode)
Attempt to push down criteria that applies to the JOIN as additional constraints on the JOIN itself.
|
protected boolean |
pushTowardsOriginatingNode(PlanNode criteriaNode,
PlanNode originatingNode)
Push the criteria node as close to the originating node as possible.
|
String |
toString() |
public static final PushSelectCriteria INSTANCE
public PlanNode execute(QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack)
OptimizerRule
execute
in interface OptimizerRule
context
- the context in which the query is being optimized; never nullplan
- the plan to be optimized; never nullruleStack
- the stack of rules that will be run after this rule; never nullprotected boolean pushDownJoinCriteria(PlanNode criteriaNode, PlanNode joinNode)
criteriaNode
- the SELECT node; may not be nulljoinNode
- the JOIN node; may not be nullprotected PlanNode findOriginatingNode(PlanNode criteriaNode, List<PlanNode> originatingNodes)
selectors
as the supplied criteria.criteriaNode
- the criteriaoriginatingNodes
- the list of nodes to searchprotected boolean pushTowardsOriginatingNode(PlanNode criteriaNode, PlanNode originatingNode)
criteriaNode
- the criteria node that is to be pushed down; may not be nulloriginatingNode
- the target node that represents the node above which the criteria node should be inserted; may not
be nullprotected PlanNode findBestChildForCriteria(PlanNode criteriaNode, PlanNode originatingNode)
protected boolean atBoundary(PlanNode criteriaNode, PlanNode originatingNode)
criteriaNode
- the criteria node; may not be nulloriginatingNode
- the originating nodeCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.