org.xcmis.search.query.optimize
Class PushWhereCriteria

java.lang.Object
  extended by org.xcmis.search.query.optimize.PushWhereCriteria
All Implemented Interfaces:
OptimizerCriteria

public class PushWhereCriteria
extends Object
implements OptimizerCriteria

An optimizer criteria that attempts to push the criteria nodes in a simple 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 WHERE plan nodes that each have
        SELECT2      a single non-join constraint that are then all AND-ed
           |         together
        SELECTn
           |
        SELECTOR
 
And after:
          ...
           |
        ACCESS
           |
        PROJECT      with the list of columns being SELECTed
           |
        WHERE1
           |         One or more WHERE plan nodes that each have
        WHERE2      a single non-join constraint that are then all AND-ed
           |         together
        WHEREn
           |
        SELECTOR
 
Here is another case, where multiple WHERE nodes above a simple JOIN and where each WHERE node applies to one or more of the SELECTOR nodes (via the named selectors). Each WHERE node that applies to a single selector will get pushed toward that source, but will have the same order relative to other WHERE nodes also pushed toward that SELECTOR. However, this rules does not push WHERE nodes that apply to multiple selectors.

Before:

          ...
           |
        PROJECT ('s1','s2')      with the list of columns being SELECTed (from 's1' and 's2' selectors)
           |
        WHERE1 ('s1')
           |                     One or more WHERE plan nodes that each have
        WHERE2 ('s2')           a single non-join constraint that are then all AND-ed
           |                     together, and that each have the selector(s) they apply to
        WHERE3 ('s1','s2')
           |
        WHERE4 ('s1')
           |
         JOIN ('s1','s2')
        /     \
       /       \
   ACCESS     ACCESS
    ('s1')    ('s2')
     |           |
   PROJECT    PROJECT
    ('s1')    ('s2')
     |           |
   SELECTOR     SELECTOR
    ('s1')    ('s2')
 
And after:
          ...
           |
        PROJECT ('s1','s2')      with the list of columns being SELECTed (from 's1' and 's2' selectors)
           |
        WHERE3 ('s1','s2')      Any WHERE plan nodes that apply to multiple selectors are left above
           |                     the ACCESS nodes.
         JOIN ('s1','s2')
        /     \
       /       \
   ACCESS     ACCESS
   ('s1')     ('s2')
     |           |
  PROJECT     PROJECT
   ('s1')     ('s2')
     |           |
  WHERE1     WHERE2
   ('s1')     ('s2')
     |           |
  WHERE4     SELECTOR
   ('s1')     ('s2')
     |
   SELECTOR
   ('s1')
 

Also, any WHERE that applies to one side of an equi-join will be applied to both sides of the JOIN.


Field Summary
static PushWhereCriteria INSTANCE
           
 
Constructor Summary
PushWhereCriteria()
           
 
Method Summary
 QueryExecutionPlan execute(QueryExecutionContext context, QueryExecutionPlan plan, LinkedList<OptimizerCriteria> criteriaStack)
          Optimize the supplied plan using the supplied context, hints, and yet-to-be-run rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final PushWhereCriteria INSTANCE
Constructor Detail

PushWhereCriteria

public PushWhereCriteria()
Method Detail

execute

public QueryExecutionPlan execute(QueryExecutionContext context,
                                  QueryExecutionPlan plan,
                                  LinkedList<OptimizerCriteria> criteriaStack)
Description copied from interface: OptimizerCriteria
Optimize the supplied plan using the supplied context, hints, and yet-to-be-run rules.

Specified by:
execute in interface OptimizerCriteria
Parameters:
context - the context in which the query is being optimized; never null
plan - the plan to be optimized; never null
criteriaStack - the stack of rules that will be run after this rule; never null
Returns:
the optimized plan; never null
See Also:
OptimizerCriteria.execute(org.xcmis.search.query.QueryExecutionContext, org.xcmis.search.query.plan.QueryExecutionPlan, java.util.LinkedList)


Copyright © 2003-2013 eXo Platform SAS. All Rights Reserved.