Class NestedLoopJoinStrategy
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.BaseJoinStrategy
-
- org.apache.derby.impl.sql.compile.NestedLoopJoinStrategy
-
- All Implemented Interfaces:
JoinStrategy
class NestedLoopJoinStrategy extends BaseJoinStrategy
-
-
Constructor Summary
Constructors Constructor Description NestedLoopJoinStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
divideUpPredicateLists(Optimizable innerTable, OptimizablePredicateList originalRestrictionList, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, OptimizablePredicateList requalificationRestrictionList, DataDictionary dd)
Divide up the predicates into different lists for different phases of the operation.boolean
doesMaterialization()
Is materialization built in to the join strategy?void
estimateCost(Optimizable innerTable, OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate costEstimate)
Get the estimated cost for the join.boolean
feasible(Optimizable innerTable, OptimizablePredicateList predList, Optimizer optimizer)
Is this join strategy feasible under the circumstances?OptimizablePredicateList
getBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates, Optimizable innerTable)
Get the base predicates for this join strategy.java.lang.String
getName()
Get the name of this join strategyjava.lang.String
getOperatorSymbol()
Get the operator symbol used to represent this join strategy in optimizer tracesint
getScanArgs(TransactionController tc, MethodBuilder mb, Optimizable innerTable, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, ExpressionClassBuilderInterface acbi, int bulkFetch, int resultRowTemplate, int colRefItem, int indexColItem, int lockMode, boolean tableLocked, int isolationLevel, int maxMemoryPerTable, boolean genInListVals)
Get the appropriate arguments to the scan for this type of join.java.lang.String
halfOuterJoinResultSetMethodName()
Get the name of the join result set method for the half outerjoinjava.lang.String
joinResultSetMethodName()
Get the name of the join result set method for the joinint
maxCapacity(int userSpecifiedCapacity, int maxMemoryPerTable, double perRowUsage)
boolean
multiplyBaseCostByOuterRows()
Returns true if the base cost of scanning the conglomerate should be multiplied by the number of outer rows.double
nonBasePredicateSelectivity(Optimizable innerTable, OptimizablePredicateList predList)
Get the extra selectivity of the non-base predicates (those that were left in the predicate list by getBasePredicates() that are not applied to the scan of the base conglomerate.void
putBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates)
Put back and base predicates that were removed from the list by getBasePredicates (see above).java.lang.String
resultSetMethodName(boolean bulkFetch, boolean multiprobe, boolean validatingCheckConstraint)
Get the name of the result set method for base table scansint
scanCostType()
Get the costing type, for use with StoreCostController.getScanCostjava.lang.String
toString()
protected boolean
validForOutermostTable()
Can this join strategy be used on the outermost table of a join.-
Methods inherited from class org.apache.derby.impl.sql.compile.BaseJoinStrategy
bulkFetchOK, fillInScanArgs1, fillInScanArgs2, ignoreBulkFetch, isHashJoin
-
-
-
-
Method Detail
-
feasible
public boolean feasible(Optimizable innerTable, OptimizablePredicateList predList, Optimizer optimizer) throws StandardException
Description copied from interface:JoinStrategy
Is this join strategy feasible under the circumstances?- Parameters:
innerTable
- The inner table of the joinpredList
- The predicateList for the joinoptimizer
- The optimizer to use- Returns:
- true means the strategy is feasible, false means it isn't
- Throws:
StandardException
- Thrown on error- See Also:
JoinStrategy.feasible(org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.Optimizer)
-
multiplyBaseCostByOuterRows
public boolean multiplyBaseCostByOuterRows()
Description copied from interface:JoinStrategy
Returns true if the base cost of scanning the conglomerate should be multiplied by the number of outer rows.
-
getBasePredicates
public OptimizablePredicateList getBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates, Optimizable innerTable) throws StandardException
Description copied from interface:JoinStrategy
Get the base predicates for this join strategy. The base predicates are the ones that can be used while scanning the table. For some join strategies (for example, nested loop), all predicates are base predicates. For other join strategies (for example, hash join), the base predicates are those that involve comparisons with constant expressions. Also, order the base predicates according to the order in the proposed conglomerate descriptor for the inner table.- Parameters:
predList
- The predicate list to pull from.basePredicates
- The list to put the base predicates in.innerTable
- The inner table of the join- Returns:
- The base predicate list. If no predicates are pulled, it may return the source predList without doing anything.
- Throws:
StandardException
- Thrown on error- See Also:
JoinStrategy.getBasePredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.Optimizable)
-
nonBasePredicateSelectivity
public double nonBasePredicateSelectivity(Optimizable innerTable, OptimizablePredicateList predList)
Description copied from interface:JoinStrategy
Get the extra selectivity of the non-base predicates (those that were left in the predicate list by getBasePredicates() that are not applied to the scan of the base conglomerate. NOTE: For some types of join strategy, it may not remove any predicates from the original predicate list. The join strategy is expected to know when it does this, and to return 1.0 as the extra selectivity in these cases.- Parameters:
innerTable
- The inner table of the join.predList
- The original predicate list that was passed to getBasePredicates(), from which some base predicates may have been pulled.- Returns:
- The extra selectivity due to non-base predicates
- See Also:
JoinStrategy.nonBasePredicateSelectivity(org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.OptimizablePredicateList)
-
putBasePredicates
public void putBasePredicates(OptimizablePredicateList predList, OptimizablePredicateList basePredicates) throws StandardException
Description copied from interface:JoinStrategy
Put back and base predicates that were removed from the list by getBasePredicates (see above). NOTE: Those join strategies that treat all predicates as base predicates may treat the get and put methods as no-ops.- Parameters:
predList
- The list of predicates to put the base predicates back in.basePredicates
- The base predicates to put back in the list.- Throws:
StandardException
- Thrown on error- See Also:
JoinStrategy.putBasePredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.OptimizablePredicateList)
-
estimateCost
public void estimateCost(Optimizable innerTable, OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, CostEstimate costEstimate)
Description copied from interface:JoinStrategy
Get the estimated cost for the join.- Parameters:
innerTable
- The inner table to join withpredList
- The predicate list for the joincd
- The conglomerate descriptor (if appropriate) to get the cost ofouterCost
- The estimated cost of the part of the plan outer to the inner tableoptimizer
- The optimizer to use to help estimate the costcostEstimate
- The estimated cost of doing a single scan of the inner table, to be filled in with the cost of doing the join.
-
maxCapacity
public int maxCapacity(int userSpecifiedCapacity, int maxMemoryPerTable, double perRowUsage)
maxMemoryPerTable
- maximum number of bytes per tableperRowUsage
- number of bytes per row- Returns:
- The maximum number of rows that can be handled by this join strategy
- See Also:
JoinStrategy.maxCapacity(int, int, double)
-
getName
public java.lang.String getName()
Description copied from interface:JoinStrategy
Get the name of this join strategy- See Also:
JoinStrategy.getName()
-
scanCostType
public int scanCostType()
Description copied from interface:JoinStrategy
Get the costing type, for use with StoreCostController.getScanCost- See Also:
JoinStrategy.scanCostType()
-
getOperatorSymbol
public java.lang.String getOperatorSymbol()
Description copied from interface:JoinStrategy
Get the operator symbol used to represent this join strategy in optimizer traces- See Also:
JoinStrategy.getOperatorSymbol()
-
resultSetMethodName
public java.lang.String resultSetMethodName(boolean bulkFetch, boolean multiprobe, boolean validatingCheckConstraint)
Description copied from interface:JoinStrategy
Get the name of the result set method for base table scans- Parameters:
bulkFetch
- True means bulk fetch is being done on the inner tablemultiprobe
- True means we are probing the inner table for rows matching a specified list of values.validatingCheckConstraint
- True of this is a special scan to validate a check constraint.- See Also:
JoinStrategy.resultSetMethodName(boolean, boolean, boolean)
-
joinResultSetMethodName
public java.lang.String joinResultSetMethodName()
Description copied from interface:JoinStrategy
Get the name of the join result set method for the join- See Also:
JoinStrategy.joinResultSetMethodName()
-
halfOuterJoinResultSetMethodName
public java.lang.String halfOuterJoinResultSetMethodName()
Description copied from interface:JoinStrategy
Get the name of the join result set method for the half outerjoin
-
getScanArgs
public int getScanArgs(TransactionController tc, MethodBuilder mb, Optimizable innerTable, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, ExpressionClassBuilderInterface acbi, int bulkFetch, int resultRowTemplate, int colRefItem, int indexColItem, int lockMode, boolean tableLocked, int isolationLevel, int maxMemoryPerTable, boolean genInListVals) throws StandardException
Description copied from interface:JoinStrategy
Get the appropriate arguments to the scan for this type of join.- Parameters:
tc
- The TransactionControllermb
- The method to generate the arguments ininnerTable
- The inner table of the joinstoreRestrictionList
- The predicate list to be evaluated in the storenonStoreRestrictionList
- The predicate list to be evaluated outside of the storeacbi
- The expression class builder for the activation class we're buildingbulkFetch
- The amount of bulk fetch to doresultRowTemplate
- The saved object index of a result row templatecolRefItem
- The item number of the column reference bit maplockMode
- The lock mode to use when scanning the table (see TransactionController).tableLocked
- Whether or not the table is marked (in sys.systables) as always using table lockingisolationLevel
- Isolation level specified (or not) for scansmaxMemoryPerTable
- Max memory per tablegenInListVals
- Whether or not we are going to generate IN-list values with which to probe the inner table.- Returns:
- Count of the expressions pushed to use as the parameters to the result set for the inner table
- Throws:
StandardException
- Thrown on error- See Also:
JoinStrategy.getScanArgs(org.apache.derby.iapi.store.access.TransactionController, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.ExpressionClassBuilderInterface, int, int, int, int, int, boolean, int, int, boolean)
-
divideUpPredicateLists
public void divideUpPredicateLists(Optimizable innerTable, OptimizablePredicateList originalRestrictionList, OptimizablePredicateList storeRestrictionList, OptimizablePredicateList nonStoreRestrictionList, OptimizablePredicateList requalificationRestrictionList, DataDictionary dd) throws StandardException
Description copied from interface:JoinStrategy
Divide up the predicates into different lists for different phases of the operation. When this method is called, all of the predicates will be in restrictionList. The effect of this method is to remove all of the predicates from restrictionList except those that will be pushed down to the store as start/stop predicates or Qualifiers. The remaining predicates will be put into nonBaseTableRestrictionList. All predicate lists will be ordered as necessary for use with the conglomerate. Some operations (like hash join) materialize results, and so require requalification of rows when doing a non-covering index scan. The predicates to use for requalification are copied into baseTableRestrictionList.- Parameters:
innerTable
- The inner table of the joinoriginalRestrictionList
- Initially contains all predicates. This method removes predicates from this list and moves them to other lists, as appropriate.storeRestrictionList
- To be filled in with predicates to be pushed down to store.nonStoreRestrictionList
- To be filled in with predicates that are not pushed down to the store.requalificationRestrictionList
- Copy of predicates used to re-qualify rows, if necessary.dd
- The DataDictionary- Throws:
StandardException
- Thrown on error- See Also:
JoinStrategy.divideUpPredicateLists(org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.dictionary.DataDictionary)
-
doesMaterialization
public boolean doesMaterialization()
Description copied from interface:JoinStrategy
Is materialization built in to the join strategy?- Returns:
- Whether or not materialization is built in to the join strategy
- See Also:
JoinStrategy.doesMaterialization()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
validForOutermostTable
protected boolean validForOutermostTable()
Can this join strategy be used on the outermost table of a join.- Overrides:
validForOutermostTable
in classBaseJoinStrategy
- Returns:
- Whether or not this join strategy can be used on the outermost table of a join.
-
-