|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.compile.OptimizerImpl
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 | |
void |
considerCost(Optimizable optimizable,
OptimizablePredicateList predList,
CostEstimate estimatedCost,
CostEstimate outerCost)
This is the version of costOptimizable for non-base-tables. |
private void |
costBasedCostOptimizable(Optimizable optimizable,
TableDescriptor td,
ConglomerateDescriptor cd,
OptimizablePredicateList predList,
CostEstimate outerCost)
This method decides whether the given conglomerate descriptor is cheapest based on cost, rather than based on rules. |
void |
costOptimizable(Optimizable optimizable,
TableDescriptor td,
ConglomerateDescriptor cd,
OptimizablePredicateList predList,
CostEstimate outerCost)
Cost the current Optimizable with the specified OPL. |
void |
costPermutation()
Cost the current permutation. |
private CostEstimate |
estimateTotalCost(OptimizablePredicateList predList,
ConglomerateDescriptor cd,
CostEstimate outerCost,
Optimizable optimizable)
Estimate the total cost of doing a join with the given optimizable. |
DataDictionary |
getDataDictionary()
Return the DataDictionary that the Optimizer is using. |
JoinStrategy |
getJoinStrategy(int whichStrategy)
Gets a join strategy by number (zero-based). |
JoinStrategy |
getJoinStrategy(java.lang.String whichStrategy)
Gets a join strategy by name. |
int |
getLevel()
Get the level of this optimizer. |
int |
getMaxMemoryPerTable()
|
CostEstimateImpl |
getNewCostEstimate(double theCost,
double theRowCount,
double theSingleScanRowCount)
|
boolean |
getNextDecoratedPermutation()
Iterate through the "decorated permutations", returning false when they are exhausted. |
boolean |
getNextPermutation()
Iterate through the permutations, returning false when the permutations are exhausted. |
int |
getNumberOfJoinStrategies()
Get the number of join strategies supported by this optimizer. |
CostEstimate |
getOptimizedCost()
Get the estimated cost of the optimized query |
private boolean |
isPushable(OptimizablePredicate pred)
|
void |
modifyAccessPaths()
Modify the access path for each Optimizable, as necessary. |
CostEstimate |
newCostEstimate()
Get a new CostEstimate object |
(package private) void |
pushPredicates(Optimizable curTable,
JBitSet outerTables)
|
private void |
rememberBestCost(CostEstimate currentCost,
int planType)
Is the cost of this join order lower than the best one we've found so far? |
private void |
rewindJoinOrder()
|
private void |
ruleBasedCostOptimizable(Optimizable optimizable,
TableDescriptor td,
ConglomerateDescriptor cd,
OptimizablePredicateList predList,
CostEstimate outerCost)
This method decides whether the given conglomerate descriptor is cheapest based on rules, rather than based on cost estimates. |
void |
setOuterRows(double outerRows)
Set the estimated number of outer rows - good for optimizing nested optimizables like subqueries and join nodes. |
int |
tableLockThreshold()
Get the maximum number of estimated rows touched in a table before we decide to open the table with table locking (as opposed to row locking. |
void |
trace(int traceFlag,
int intParam1,
int intParam2,
double doubleParam,
java.lang.Object objectParam1)
Optimizer trace. |
double |
uniqueJoinWithOuterTable(OptimizablePredicateList predList)
Tells whether any of the tables outer to the current one has a uniqueness condition on the given predicate list, and if so, how many times each unique key can be seen by the current table. |
boolean |
useStatistics()
If statistics should be considered by the optimizer while optimizing a query. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
DataDictionary dDictionary
int numTablesInQuery
int numOptimizables
protected JBitSet assignedTableMap
protected OptimizableList optimizableList
OptimizablePredicateList predicateList
JBitSet nonCorrelatedTableMap
protected int[] proposedJoinOrder
protected int[] bestJoinOrder
protected int joinPosition
boolean desiredJoinOrderFound
private static final int NO_JUMP
private static final int READY_TO_JUMP
private static final int JUMPING
private static final int WALK_HIGH
private static final int WALK_LOW
private int permuteState
private int[] firstLookOrder
private boolean ruleBasedOptimization
private CostEstimateImpl outermostCostEstimate
protected CostEstimateImpl currentCost
protected CostEstimateImpl currentSortAvoidanceCost
protected CostEstimateImpl bestCost
protected long timeOptimizationStarted
protected long currentTime
protected boolean timeExceeded
private boolean noTimeout
private boolean useStatistics
private int tableLockThreshold
private JoinStrategy[] joinStrategies
protected RequiredRowOrdering requiredRowOrdering
private boolean foundABestPlan
protected CostEstimate sortCost
private RowOrdering currentRowOrdering
private RowOrdering bestRowOrdering
private boolean conglomerate_OneRowResultSet
protected boolean optimizerTrace
protected boolean optimizerTraceHtml
protected int maxMemoryPerTable
Constructor Detail |
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
Method Detail |
public int getMaxMemoryPerTable()
getMaxMemoryPerTable
in interface Optimizer
public boolean getNextPermutation() throws StandardException
Optimizer
getNextPermutation
in interface Optimizer
StandardException
- Thrown on errorOptimizer.getNextPermutation()
private void rewindJoinOrder() throws StandardException
StandardException
void pushPredicates(Optimizable curTable, JBitSet outerTables) throws StandardException
StandardException
public boolean getNextDecoratedPermutation() throws StandardException
Optimizer
getNextDecoratedPermutation
in interface Optimizer
StandardException
- Thrown on errorOptimizer.getNextDecoratedPermutation()
private void rememberBestCost(CostEstimate currentCost, int planType) throws StandardException
StandardException
- Thrown on errorpublic void costPermutation() throws StandardException
Optimizer
costPermutation
in interface Optimizer
StandardException
- Thrown on errorOptimizer.costPermutation()
public void costOptimizable(Optimizable optimizable, TableDescriptor td, ConglomerateDescriptor cd, OptimizablePredicateList predList, CostEstimate outerCost) throws StandardException
Optimizer
costOptimizable
in interface Optimizer
optimizable
- The Optimizabletd
- TableDescriptor of the Optimizablecd
- The ConglomerateDescriptor for the conglom to cost
(This should change to an object to represent
access paths, but for now this is OK).predList
- The OptimizablePredicateList to applyouterCost
- The cost of the tables outer to the one being
optimizer - tells how many outer rows there are.
StandardException
- Thrown on errorOptimizer.costOptimizable(org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.dictionary.TableDescriptor, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.CostEstimate)
private void ruleBasedCostOptimizable(Optimizable optimizable, TableDescriptor td, ConglomerateDescriptor cd, OptimizablePredicateList predList, CostEstimate outerCost) throws StandardException
StandardException
private void costBasedCostOptimizable(Optimizable optimizable, TableDescriptor td, ConglomerateDescriptor cd, OptimizablePredicateList predList, CostEstimate outerCost) throws StandardException
StandardException
public void considerCost(Optimizable optimizable, OptimizablePredicateList predList, CostEstimate estimatedCost, CostEstimate outerCost) throws StandardException
considerCost
in interface Optimizer
optimizable
- The OptimizablepredList
- The OptimizablePredicateList to applyestimatedCost
- The estimated cost of the given optimizableouterCost
- The cost of the tables outer to the one being
optimizer - tells how many outer rows there are.
StandardException
- Thrown on errorOptimizer.considerCost(org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.CostEstimate, org.apache.derby.iapi.sql.compile.CostEstimate)
public DataDictionary getDataDictionary()
Optimizer
getDataDictionary
in interface Optimizer
Optimizer.getDataDictionary()
public void modifyAccessPaths() throws StandardException
Optimizer
modifyAccessPaths
in interface Optimizer
StandardException
- Thrown on errorOptimizer.modifyAccessPaths()
public CostEstimate newCostEstimate()
Optimizer
newCostEstimate
in interface Optimizer
Optimizer.newCostEstimate()
public CostEstimate getOptimizedCost()
Optimizer
getOptimizedCost
in interface Optimizer
Optimizer.getOptimizedCost()
public void setOuterRows(double outerRows)
Optimizer
setOuterRows
in interface Optimizer
Optimizer.setOuterRows(double)
public int tableLockThreshold()
Optimizer
tableLockThreshold
in interface Optimizer
Optimizer.tableLockThreshold()
public int getNumberOfJoinStrategies()
getNumberOfJoinStrategies
in interface Optimizer
public JoinStrategy getJoinStrategy(int whichStrategy)
Optimizer
getJoinStrategy
in interface Optimizer
Optimizer.getJoinStrategy(int)
public JoinStrategy getJoinStrategy(java.lang.String whichStrategy)
Optimizer
getJoinStrategy
in interface Optimizer
Optimizer.getJoinStrategy(int)
public double uniqueJoinWithOuterTable(OptimizablePredicateList predList) throws StandardException
Optimizer
uniqueJoinWithOuterTable
in interface Optimizer
predList
- The predicate list to check
StandardException
- Thrown on errorOptimizer.uniqueJoinWithOuterTable(org.apache.derby.iapi.sql.compile.OptimizablePredicateList)
private boolean isPushable(OptimizablePredicate pred)
private CostEstimate estimateTotalCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizable optimizable) throws StandardException
StandardException
- Thrown on errorpublic int getLevel()
Optimizer
getLevel
in interface Optimizer
Optimizer.getLevel()
public CostEstimateImpl getNewCostEstimate(double theCost, double theRowCount, double theSingleScanRowCount)
public void trace(int traceFlag, int intParam1, int intParam2, double doubleParam, java.lang.Object objectParam1)
Optimizer
trace
in interface Optimizer
public boolean useStatistics()
Optimizer
useStatistics
in interface Optimizer
Optimizer.useStatistics()
|
Built on Tue 2006-10-10 19:23:47+0200, from revision exported | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |