Optimizer provides services for optimizing a query.
RESOLVE:
o Need to figure out what to do about subqueries, figuring out
their attachment points and how to communicate them back to the
caller.
prepForNextRound() Prepare for another round of optimization.
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_ Optimizer and the time a call to this Optimizer's
getNextPermutation() method returns FALSE.
public void
setOuterRows(double outerRowCount) Set the estimated number of outer rows - good for optimizing nested
optimizables like subqueries and join nodes.
public 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.
public void
trace(int traceFlag, int intParam1, int intParam2, double doubleParam, 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.
Parameters: predList - The predicate list to check <= 0 means there is no uniqueness condition> 0 means there is a uniqueness condition on anouter table, and the return value is the reciprocal ofthe maximum number of times the optimizer estimates that eachunique key will be returned.
public boolean
useStatistics() If statistics should be considered by the optimizer while optimizing
a query.
Field Detail
ADDING_UNORDERED_OPTIMIZABLE
final public static int ADDING_UNORDERED_OPTIMIZABLE(Code)
CALLING_NEXT_ACCESS_PATH
final public static int CALLING_NEXT_ACCESS_PATH(Code)
CALLING_ON_JOIN_NODE
final public static int CALLING_ON_JOIN_NODE(Code)
CHANGING_ACCESS_PATH_FOR_TABLE
final public static int CHANGING_ACCESS_PATH_FOR_TABLE(Code)
CHEAPEST_PLAN_SO_FAR
final public static int CHEAPEST_PLAN_SO_FAR(Code)
Property name for controlling the maximum size of memory (in KB)
the optimizer can use for each table. If an access path takes
memory larger than that size for a table, the access path is skipped.
Default is 1024 (KB).
MODIFYING_ACCESS_PATHS
final public static int MODIFYING_ACCESS_PATHS(Code)
Consider the cost of the given optimizable. This method is like
costOptimizable, above, but it is used when the Optimizable does
not need help from the optimizer in costing the Optimizable (in practice,
all Optimizables except FromBaseTable use this method.
Caller is responsible for pushing all predicates which can be evaluated
prior to costing.
Parameters: optimizable - The Optimizable Parameters: predList - The OptimizablePredicateList to apply Parameters: estimatedCost - The estimated cost of the given optimizable Parameters: outerCost - The cost of the tables outer to the one beingoptimizer - tells how many outer rows there are. exception: StandardException - Thrown on error
Cost the current Optimizable with the specified OPL.
Caller is responsible for pushing all predicates which can be evaluated
prior to costing.
Parameters: optimizable - The Optimizable Parameters: td - TableDescriptor of the Optimizable Parameters: cd - The ConglomerateDescriptor for the conglom to cost(This should change to an object to representaccess paths, but for now this is OK). Parameters: predList - The OptimizablePredicateList to apply Parameters: outerCost - The cost of the tables outer to the one beingoptimizer - tells how many outer rows there are. exception: StandardException - Thrown on error
Cost the current permutation.
Caller is responsible for pushing all predicates which can be evaluated
prior to costing.
exception: StandardException - Thrown on error
Return the DataDictionary that the Optimizer is using.
This is useful when an Optimizable needs to call optimize() on
a child ResultSetNode.
DataDictionary DataDictionary that the Optimizer is using.
Get the final estimated cost of the optimized query. This
should be the cost that corresponds to the best overall join
order chosen by the optimizer, and thus this method should
only be called after optimization is complete (i.e. when
modifying access paths).
Iterate through the "decorated permutations", returning false when they
are exhausted.
NOTE - Implementers are responsible for hiding tree pruning of access
methods behind this method call.
boolean True - An optimizable decorated permutation remains.False - Decorated permutations are exhausted. exception: StandardException - Thrown on error
Iterate through the permutations, returning false when the permutations
are exhausted.
NOTE - Implementers are responsible for hiding tree pruning of permutations
behind this method call.
boolean True - An optimizable permutation remains.False - Permutations are exhausted. exception: StandardException - Thrown on error
Modify the access path for each Optimizable, as necessary. This includes
things like adding result sets to translate from index rows to base rows.
exception: StandardException - Thrown on error
Prepare for another round of optimization.
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_ Optimizer and the time a call to this Optimizer's
getNextPermutation() method returns FALSE. Any re-initialization
of state that is required before each round should be done in this
method.
setOuterRows
public void setOuterRows(double outerRowCount)(Code)
Set the estimated number of outer rows - good for optimizing nested
optimizables like subqueries and join nodes.
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.
Parameters: predList - The predicate list to check <= 0 means there is no uniqueness condition> 0 means there is a uniqueness condition on anouter table, and the return value is the reciprocal ofthe maximum number of times the optimizer estimates that eachunique key will be returned. For example, 0.5 means theoptimizer thinks each distinct join key will be returnedat most twice. exception: StandardException - Thrown on error
If statistics should be considered by the optimizer while optimizing
a query. The user may disable the use of statistics by setting the
property derby.optimizer.useStatistics or by using the property
useStatistics in a query.
See Also:Optimizer.USE_STATISTICS