| java.lang.Object org.apache.derby.impl.sql.compile.OptimizerImpl
All known Subclasses: org.apache.derby.impl.sql.compile.Level2OptimizerImpl,
OptimizerImpl | public class OptimizerImpl implements Optimizer(Code) | | This will be the Level 1 Optimizer.
RESOLVE - it's a level 0 optimizer right now.
Current State:
o No costing services
o We can only cost a derived table with a join once.
Optimizer uses OptimizableList to keep track of the best join order as it
builds it. For each available slot in the join order, we cost all of the
Optimizables from that slot til the end of the OptimizableList. Later,
we will choose the best Optimizable for that slot and reorder the list
accordingly.
In order to do this, we probably need to move the temporary pushing and
pulling of join clauses into Optimizer, since the logic will be different
for other implementations. (Of course, we're not pushing and pulling join
clauses between permutations yet.)
|
Constructor Summary | |
protected | OptimizerImpl(OptimizableList optimizableList, OptimizablePredicateList predicateList, DataDictionary dDictionary, boolean ruleBasedOptimization, boolean noTimeout, boolean useStatistics, int maxMemoryPerTable, JoinStrategy[] joinStrategies, int tableLockThreshold, RequiredRowOrdering requiredRowOrdering, int numTablesInQuery) |
Method Summary | |
protected void | addScopedPredicatesToList(PredicateList pList) Add scoped predicates to this optimizer's predicateList. | public void | considerCost(Optimizable optimizable, OptimizablePredicateList predList, CostEstimate estimatedCost, CostEstimate outerCost) This is the version of costOptimizable for non-base-tables. | public void | costOptimizable(Optimizable optimizable, TableDescriptor td, ConglomerateDescriptor cd, OptimizablePredicateList predList, CostEstimate outerCost) | public void | costPermutation() | public DataDictionary | getDataDictionary() | public CostEstimate | getFinalCost() See Also: Optimizer.getFinalCost See Also: Sum up the cost of all of the trulyTheBestAccessPaths See Also: for the Optimizables in our list. | public JoinStrategy | getJoinStrategy(int whichStrategy) | public JoinStrategy | getJoinStrategy(String whichStrategy) | public int | getLevel() | public int | getMaxMemoryPerTable() | public CostEstimateImpl | getNewCostEstimate(double theCost, double theRowCount, double theSingleScanRowCount) | public boolean | getNextDecoratedPermutation() | public boolean | getNextPermutation() | public int | getNumberOfJoinStrategies() Get the number of join strategies supported by this optimizer. | public CostEstimate | getOptimizedCost() | public void | modifyAccessPaths() | public CostEstimate | newCostEstimate() | public void | prepForNextRound() This method is called before every "round" of optimization, where
we define a "round" to be the period between the last time a call to
getOptimizer() (on either a ResultSetNode or an OptimizerFactory)
returned _this_ OptimizerImpl and the time a call to this OptimizerImpl's
getNextPermutation() method returns FALSE. | void | pushPredicates(Optimizable curTable, JBitSet outerTables) | public void | setOuterRows(double outerRows) | public int | tableLockThreshold() | public void | trace(int traceFlag, int intParam1, int intParam2, double doubleParam, Object objectParam1) | public double | uniqueJoinWithOuterTable(OptimizablePredicateList predList) | protected void | updateBestPlanMaps(short action, Object planKey) Process (i.e. | public boolean | useStatistics() |
bestJoinOrder | protected int[] bestJoinOrder(Code) | | |
currentTime | protected long currentTime(Code) | | |
desiredJoinOrderFound | boolean desiredJoinOrderFound(Code) | | |
joinPosition | protected int joinPosition(Code) | | |
maxMemoryPerTable | protected int maxMemoryPerTable(Code) | | |
numOptimizables | int numOptimizables(Code) | | |
numTablesInQuery | int numTablesInQuery(Code) | | |
optimizerTrace | protected boolean optimizerTrace(Code) | | |
optimizerTraceHtml | protected boolean optimizerTraceHtml(Code) | | |
proposedJoinOrder | protected int[] proposedJoinOrder(Code) | | |
timeExceeded | protected boolean timeExceeded(Code) | | |
timeLimit | protected double timeLimit(Code) | | |
timeOptimizationStarted | protected long timeOptimizationStarted(Code) | | |
OptimizerImpl | protected OptimizerImpl(OptimizableList optimizableList, OptimizablePredicateList predicateList, DataDictionary dDictionary, boolean ruleBasedOptimization, boolean noTimeout, boolean useStatistics, int maxMemoryPerTable, JoinStrategy[] joinStrategies, int tableLockThreshold, RequiredRowOrdering requiredRowOrdering, int numTablesInQuery) throws StandardException(Code) | | |
addScopedPredicatesToList | protected void addScopedPredicatesToList(PredicateList pList) throws StandardException(Code) | | Add scoped predicates to this optimizer's predicateList. This method
is intended for use during the modifyAccessPath() phase of
compilation, as it allows nodes (esp. SelectNodes) to add to the
list of predicates available for the final "push" before code
generation. Just as the constructor for this class allows a
caller to specify a predicate list to use during the optimization
phase, this method allows a caller to specify a predicate list to
use during the modify-access-paths phase.
Before adding the received predicates, this method also
clears out any scoped predicates that might be sitting in
OptimizerImpl's list from the last round of optimizing.
Parameters: pList - List of predicates to add to this OptimizerImpl'sown list for pushing. |
getFinalCost | public CostEstimate getFinalCost()(Code) | | See Also: Optimizer.getFinalCost See Also: Sum up the cost of all of the trulyTheBestAccessPaths See Also: for the Optimizables in our list. Assumption is that See Also: we only get here after optimization has completed--i.e. See Also: while modifying access paths. |
getMaxMemoryPerTable | public int getMaxMemoryPerTable()(Code) | | |
getNewCostEstimate | public CostEstimateImpl getNewCostEstimate(double theCost, double theRowCount, double theSingleScanRowCount)(Code) | | |
getNumberOfJoinStrategies | public int getNumberOfJoinStrategies()(Code) | | Get the number of join strategies supported by this optimizer.
|
prepForNextRound | public void prepForNextRound()(Code) | | This method is called before every "round" of optimization, where
we define a "round" to be the period between the last time a call to
getOptimizer() (on either a ResultSetNode or an OptimizerFactory)
returned _this_ OptimizerImpl and the time a call to this OptimizerImpl's
getNextPermutation() method returns FALSE. Any re-initialization
of state that is required before each round should be done in this
method.
|
trace | public void trace(int traceFlag, int intParam1, int intParam2, double doubleParam, Object objectParam1)(Code) | | |
updateBestPlanMaps | protected void updateBestPlanMaps(short action, Object planKey) throws StandardException(Code) | | Process (i.e. add, load, or remove) current best join order as the
best one for some outer query or ancestor node, represented by another
OptimizerImpl or an instance of FromTable, respectively. Then
iterate through our optimizableList and tell each Optimizable
to do the same. See Optimizable.updateBestPlan() for more on why
this is necessary.
Parameters: action - Indicates whether to add, load, or remove the plan Parameters: planKey - Object to use as the map key when adding/looking upa plan. If this is an instance of OptimizerImpl then it correspondsto an outer query; otherwise it's some Optimizable above thisOptimizerImpl that could potentially reject plans chosen by thisOptimizerImpl. |
|
|