Class DefaultOptTrace
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.DefaultOptTrace
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuilder
_buffer
-
Constructor Summary
Constructors Constructor Description DefaultOptTrace()
Make a DefaultOptTrace
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
appendTraceString(java.lang.String traceString)
Append a string to the optimizer tracevoid
printToWriter(java.io.PrintWriter out)
Print the trace so far.private java.lang.String
reportConglomerateDescriptor(ConglomerateDescriptor cd)
private java.lang.String
reportCostForTable(java.lang.Object cost, int tableNumber)
private java.lang.String
reportCostIncluding(java.lang.String selectivityType, CostEstimate cost, int tableNumber)
private java.lang.String
reportJoinOrder(java.lang.String prefix, boolean addJoinOrderNumber, int joinOrderNumber, int joinPosition, int[] joinOrder, JBitSet assignedTableMap)
void
traceAddingUnorderedOptimizable(int predicateCount)
Say that we're adding an unordered optimizable.void
traceChangingAccessPathForTable(int tableNumber)
Say that we're considering a different access path for a table.void
traceCheapestPlanSoFar(int planType, CostEstimate currentCost)
Report the cost of the cheapest plan so far.void
traceCompleteJoinOrder()
Say that we have a complete join order.void
traceCompositeSelectivityFromStatistics(double statCompositeSelectivity)
Report the selectivity calculated from SYSSTATISTICS.void
traceConsideringConglomerate(ConglomerateDescriptor cd, int tableNumber)
Report that we are considering a conglomerate for a table.void
traceConsideringJoinStrategy(JoinStrategy js, int tableNumber)
Say that we're considering a particular join strategy on a particular table.void
traceConstantStartStopPositions()
Say that we're setting the lock mode to MODE_RECORD because the start and stop positions are all constant.void
traceCostIncludingCompositeSelectivityFromStats(CostEstimate cost, int tableNumber)
Report the cost based on selectivities coming out of SYSSTATISTICS.void
traceCostIncludingExtra1stColumnSelectivity(CostEstimate cost, int tableNumber)
Report the cost of a scan given the selectivity of an extra first column.void
traceCostIncludingExtraNonQualifierSelectivity(CostEstimate cost, int tableNumber)
Report the cost if we include an extra non-qualifier.void
traceCostIncludingExtraQualifierSelectivity(CostEstimate cost, int tableNumber)
Report the cost if we include an extra qualifier.void
traceCostIncludingExtraStartStop(CostEstimate cost, int tableNumber)
Report the cost if we include an extra start/stop.void
traceCostIncludingStatsForIndex(CostEstimate cost, int tableNumber)
Report the cost based on index statistics.void
traceCostOfConglomerateScan(int tableNumber, ConglomerateDescriptor cd, CostEstimate costEstimate, int numExtraFirstColumnPreds, double extraFirstColumnSelectivity, int numExtraStartStopPreds, double extraStartStopSelectivity, int startStopPredCount, double statStartStopSelectivity, int numExtraQualifiers, double extraQualifierSelectivity, int numExtraNonQualifiers, double extraNonQualifierSelectivity)
Report the cost of a conglomerate scan.void
traceCostOfNoncoveringIndex(CostEstimate cost, int tableNumber)
Report the cost of using a non-covering index.void
traceCostOfNScans(int tableNumber, double rowCount, CostEstimate cost)
Report the cost of scanning a table a certain number of timesvoid
traceCostWithoutSortAvoidance(CostEstimate currentCost)
Report the cost without a sort.void
traceCostWithSortAvoidance(CostEstimate currentSortAvoidanceCost)
Report the cost with sort avoidance.void
traceCurrentPlanAvoidsSort(CostEstimate bestCost, CostEstimate currentSortAvoidanceCost)
Say that the current plan avoids a sort.void
traceEndQueryBlock()
End tracing the optimization of a query block.void
traceEstimatingCostOfConglomerate(ConglomerateDescriptor cd, int tableNumber)
Report the cost of using a particular conglomerate to scan a table.void
traceHashKeyColumns(int[] hashKeyColumns)
Report the columns being tracedvoid
traceIllegalUserJoinOrder()
Say that the user specified an impossible join order.void
traceJoinOrderConsideration(int joinPosition, int[] proposedJoinOrder, JBitSet assignedTableMap)
Say that we're considering a join order.void
traceLookingForSpecifiedIndex(java.lang.String indexName, int tableNumber)
Say that we're looking for an index specified by optimizer hints.void
traceModifyingAccessPaths(int optimizerID)
Say that we're modifying access paths.void
traceNextAccessPath(java.lang.String baseTable, int predicateCount)
Report that we are advancing to the next access path for the table.void
traceNoBestPlan()
Say that we couldn't find a best plan.void
traceNoMoreConglomerates(int tableNumber)
Say that we have exhausted the conglomerate possibilities for a table.void
traceNonCoveringIndexCost(double cost, int tableNumber)
Say that we're considering a non-covering index.void
traceNoStartStopPosition()
Say that we're setting the lock mode to MODE_TABLE because there is no start/stop position.void
traceOptimizingJoinNode()
Say that we're starting to optimize a join nodevoid
traceRememberingBestAccessPath(AccessPath accessPath, int tableNumber, int planType)
Report that we've found a best access path.void
traceRememberingBestAccessPathSubstring(AccessPath ap, int tableNumber)
Report the best access path for the table so far.void
traceRememberingBestJoinOrder(int joinPosition, int[] bestJoinOrder, int planType, CostEstimate planCost, JBitSet assignedTableMap)
Say that we are remembering the current plan as the best join order so far.void
traceRememberingBestSortAvoidanceAccessPathSubstring(AccessPath ap, int tableNumber)
Report the best sort-avoiding access path for this table so far.void
traceRememberingBestUnknownAccessPathSubstring(AccessPath ap, int tableNumber)
Report an optimizer failure, e.g., while optimizing an outer joinvoid
traceRememberingJoinStrategy(JoinStrategy joinStrategy, int tableNumber)
Say that we've found a new best join strategy for the table.void
traceScanningHeapWithUniqueKey()
Say that we're considering scanning a heap even though we have a unique key match.void
traceShortCircuiting(boolean timeExceeded, Optimizable thisOpt, int joinPosition)
Say that we short-circuited a join order.void
traceSingleMatchedRowCost(double cost, int tableNumber)
Report the cost of a scan which will match exactly one row.void
traceSkipHashJoinNoHashKeys()
Say we won't consider a hash join because there are no hash key columns.void
traceSkippingBecauseTooMuchMemory(int maxMemoryPerTable)
Say that we are skipping a plan because it consumes too much memory.void
traceSkippingJoinOrder(int nextOptimizable, int joinPosition, int[] proposedJoinOrder, JBitSet assignedTableMap)
Say that we're skipping the join order starting with the next optimizable.void
traceSkipUnmaterializableHashJoin()
Say that we won't consider a hash join because the result can't be materializedvoid
traceSortCost(CostEstimate sortCost, CostEstimate currentCost)
Report the sort cost.void
traceSortNeededForOrdering(int planType, RequiredRowOrdering requiredRowOrdering)
Report that this plan needs a sortvoid
traceStartQueryBlock(long timeOptimizationStarted, int optimizerID, OptimizableList optimizableList)
Start optimizer tracing for a query block.void
traceStartStatement(java.lang.String statementText)
Start the start of tracing a statement.void
traceTimeout(long currentTime, CostEstimate bestCost)
Say that the optimizer ran out of time.void
traceUserJoinOrderOptimized()
Say that we have optimized the user-specified join order.void
traceVacuous()
Say that there's nothing to optimizer.
-
-
-
Method Detail
-
traceStartStatement
public void traceStartStatement(java.lang.String statementText)
Description copied from interface:OptTrace
Start the start of tracing a statement.- Specified by:
traceStartStatement
in interfaceOptTrace
-
traceStartQueryBlock
public void traceStartQueryBlock(long timeOptimizationStarted, int optimizerID, OptimizableList optimizableList)
Description copied from interface:OptTrace
Start optimizer tracing for a query block.- Specified by:
traceStartQueryBlock
in interfaceOptTrace
-
traceEndQueryBlock
public void traceEndQueryBlock()
Description copied from interface:OptTrace
End tracing the optimization of a query block.- Specified by:
traceEndQueryBlock
in interfaceOptTrace
-
traceTimeout
public void traceTimeout(long currentTime, CostEstimate bestCost)
Description copied from interface:OptTrace
Say that the optimizer ran out of time.- Specified by:
traceTimeout
in interfaceOptTrace
-
traceVacuous
public void traceVacuous()
Description copied from interface:OptTrace
Say that there's nothing to optimizer.- Specified by:
traceVacuous
in interfaceOptTrace
-
traceCompleteJoinOrder
public void traceCompleteJoinOrder()
Description copied from interface:OptTrace
Say that we have a complete join order.- Specified by:
traceCompleteJoinOrder
in interfaceOptTrace
-
traceSortCost
public void traceSortCost(CostEstimate sortCost, CostEstimate currentCost)
Description copied from interface:OptTrace
Report the sort cost.- Specified by:
traceSortCost
in interfaceOptTrace
-
traceNoBestPlan
public void traceNoBestPlan()
Description copied from interface:OptTrace
Say that we couldn't find a best plan.- Specified by:
traceNoBestPlan
in interfaceOptTrace
-
traceModifyingAccessPaths
public void traceModifyingAccessPaths(int optimizerID)
Description copied from interface:OptTrace
Say that we're modifying access paths.- Specified by:
traceModifyingAccessPaths
in interfaceOptTrace
-
traceShortCircuiting
public void traceShortCircuiting(boolean timeExceeded, Optimizable thisOpt, int joinPosition)
Description copied from interface:OptTrace
Say that we short-circuited a join order.- Specified by:
traceShortCircuiting
in interfaceOptTrace
-
traceSkippingJoinOrder
public void traceSkippingJoinOrder(int nextOptimizable, int joinPosition, int[] proposedJoinOrder, JBitSet assignedTableMap)
Description copied from interface:OptTrace
Say that we're skipping the join order starting with the next optimizable.- Specified by:
traceSkippingJoinOrder
in interfaceOptTrace
-
traceIllegalUserJoinOrder
public void traceIllegalUserJoinOrder()
Description copied from interface:OptTrace
Say that the user specified an impossible join order.- Specified by:
traceIllegalUserJoinOrder
in interfaceOptTrace
-
traceUserJoinOrderOptimized
public void traceUserJoinOrderOptimized()
Description copied from interface:OptTrace
Say that we have optimized the user-specified join order.- Specified by:
traceUserJoinOrderOptimized
in interfaceOptTrace
-
traceJoinOrderConsideration
public void traceJoinOrderConsideration(int joinPosition, int[] proposedJoinOrder, JBitSet assignedTableMap)
Description copied from interface:OptTrace
Say that we're considering a join order.- Specified by:
traceJoinOrderConsideration
in interfaceOptTrace
-
traceCostWithoutSortAvoidance
public void traceCostWithoutSortAvoidance(CostEstimate currentCost)
Description copied from interface:OptTrace
Report the cost without a sort.- Specified by:
traceCostWithoutSortAvoidance
in interfaceOptTrace
-
traceCostWithSortAvoidance
public void traceCostWithSortAvoidance(CostEstimate currentSortAvoidanceCost)
Description copied from interface:OptTrace
Report the cost with sort avoidance.- Specified by:
traceCostWithSortAvoidance
in interfaceOptTrace
-
traceCurrentPlanAvoidsSort
public void traceCurrentPlanAvoidsSort(CostEstimate bestCost, CostEstimate currentSortAvoidanceCost)
Description copied from interface:OptTrace
Say that the current plan avoids a sort.- Specified by:
traceCurrentPlanAvoidsSort
in interfaceOptTrace
-
traceCheapestPlanSoFar
public void traceCheapestPlanSoFar(int planType, CostEstimate currentCost)
Description copied from interface:OptTrace
Report the cost of the cheapest plan so far.- Specified by:
traceCheapestPlanSoFar
in interfaceOptTrace
-
traceSortNeededForOrdering
public void traceSortNeededForOrdering(int planType, RequiredRowOrdering requiredRowOrdering)
Description copied from interface:OptTrace
Report that this plan needs a sort- Specified by:
traceSortNeededForOrdering
in interfaceOptTrace
-
traceRememberingBestJoinOrder
public void traceRememberingBestJoinOrder(int joinPosition, int[] bestJoinOrder, int planType, CostEstimate planCost, JBitSet assignedTableMap)
Description copied from interface:OptTrace
Say that we are remembering the current plan as the best join order so far.- Specified by:
traceRememberingBestJoinOrder
in interfaceOptTrace
-
traceSkippingBecauseTooMuchMemory
public void traceSkippingBecauseTooMuchMemory(int maxMemoryPerTable)
Description copied from interface:OptTrace
Say that we are skipping a plan because it consumes too much memory.- Specified by:
traceSkippingBecauseTooMuchMemory
in interfaceOptTrace
-
traceCostOfNScans
public void traceCostOfNScans(int tableNumber, double rowCount, CostEstimate cost)
Description copied from interface:OptTrace
Report the cost of scanning a table a certain number of times- Specified by:
traceCostOfNScans
in interfaceOptTrace
-
traceSkipUnmaterializableHashJoin
public void traceSkipUnmaterializableHashJoin()
Description copied from interface:OptTrace
Say that we won't consider a hash join because the result can't be materialized- Specified by:
traceSkipUnmaterializableHashJoin
in interfaceOptTrace
-
traceSkipHashJoinNoHashKeys
public void traceSkipHashJoinNoHashKeys()
Description copied from interface:OptTrace
Say we won't consider a hash join because there are no hash key columns.- Specified by:
traceSkipHashJoinNoHashKeys
in interfaceOptTrace
-
traceHashKeyColumns
public void traceHashKeyColumns(int[] hashKeyColumns)
Description copied from interface:OptTrace
Report the columns being traced- Specified by:
traceHashKeyColumns
in interfaceOptTrace
-
traceOptimizingJoinNode
public void traceOptimizingJoinNode()
Description copied from interface:OptTrace
Say that we're starting to optimize a join node- Specified by:
traceOptimizingJoinNode
in interfaceOptTrace
-
traceConsideringJoinStrategy
public void traceConsideringJoinStrategy(JoinStrategy js, int tableNumber)
Description copied from interface:OptTrace
Say that we're considering a particular join strategy on a particular table.- Specified by:
traceConsideringJoinStrategy
in interfaceOptTrace
-
traceRememberingBestAccessPath
public void traceRememberingBestAccessPath(AccessPath accessPath, int tableNumber, int planType)
Description copied from interface:OptTrace
Report that we've found a best access path.- Specified by:
traceRememberingBestAccessPath
in interfaceOptTrace
-
traceNoMoreConglomerates
public void traceNoMoreConglomerates(int tableNumber)
Description copied from interface:OptTrace
Say that we have exhausted the conglomerate possibilities for a table.- Specified by:
traceNoMoreConglomerates
in interfaceOptTrace
-
traceConsideringConglomerate
public void traceConsideringConglomerate(ConglomerateDescriptor cd, int tableNumber)
Description copied from interface:OptTrace
Report that we are considering a conglomerate for a table.- Specified by:
traceConsideringConglomerate
in interfaceOptTrace
-
traceScanningHeapWithUniqueKey
public void traceScanningHeapWithUniqueKey()
Description copied from interface:OptTrace
Say that we're considering scanning a heap even though we have a unique key match.- Specified by:
traceScanningHeapWithUniqueKey
in interfaceOptTrace
-
traceAddingUnorderedOptimizable
public void traceAddingUnorderedOptimizable(int predicateCount)
Description copied from interface:OptTrace
Say that we're adding an unordered optimizable.- Specified by:
traceAddingUnorderedOptimizable
in interfaceOptTrace
-
traceChangingAccessPathForTable
public void traceChangingAccessPathForTable(int tableNumber)
Description copied from interface:OptTrace
Say that we're considering a different access path for a table.- Specified by:
traceChangingAccessPathForTable
in interfaceOptTrace
-
traceNoStartStopPosition
public void traceNoStartStopPosition()
Description copied from interface:OptTrace
Say that we're setting the lock mode to MODE_TABLE because there is no start/stop position.- Specified by:
traceNoStartStopPosition
in interfaceOptTrace
-
traceNonCoveringIndexCost
public void traceNonCoveringIndexCost(double cost, int tableNumber)
Description copied from interface:OptTrace
Say that we're considering a non-covering index.- Specified by:
traceNonCoveringIndexCost
in interfaceOptTrace
-
traceConstantStartStopPositions
public void traceConstantStartStopPositions()
Description copied from interface:OptTrace
Say that we're setting the lock mode to MODE_RECORD because the start and stop positions are all constant.- Specified by:
traceConstantStartStopPositions
in interfaceOptTrace
-
traceEstimatingCostOfConglomerate
public void traceEstimatingCostOfConglomerate(ConglomerateDescriptor cd, int tableNumber)
Description copied from interface:OptTrace
Report the cost of using a particular conglomerate to scan a table.- Specified by:
traceEstimatingCostOfConglomerate
in interfaceOptTrace
-
traceLookingForSpecifiedIndex
public void traceLookingForSpecifiedIndex(java.lang.String indexName, int tableNumber)
Description copied from interface:OptTrace
Say that we're looking for an index specified by optimizer hints.- Specified by:
traceLookingForSpecifiedIndex
in interfaceOptTrace
-
traceSingleMatchedRowCost
public void traceSingleMatchedRowCost(double cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost of a scan which will match exactly one row.- Specified by:
traceSingleMatchedRowCost
in interfaceOptTrace
-
traceCostIncludingExtra1stColumnSelectivity
public void traceCostIncludingExtra1stColumnSelectivity(CostEstimate cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost of a scan given the selectivity of an extra first column.- Specified by:
traceCostIncludingExtra1stColumnSelectivity
in interfaceOptTrace
-
traceNextAccessPath
public void traceNextAccessPath(java.lang.String baseTable, int predicateCount)
Description copied from interface:OptTrace
Report that we are advancing to the next access path for the table.- Specified by:
traceNextAccessPath
in interfaceOptTrace
-
traceCostIncludingExtraStartStop
public void traceCostIncludingExtraStartStop(CostEstimate cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost if we include an extra start/stop.- Specified by:
traceCostIncludingExtraStartStop
in interfaceOptTrace
-
traceCostIncludingExtraQualifierSelectivity
public void traceCostIncludingExtraQualifierSelectivity(CostEstimate cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost if we include an extra qualifier.- Specified by:
traceCostIncludingExtraQualifierSelectivity
in interfaceOptTrace
-
traceCostIncludingExtraNonQualifierSelectivity
public void traceCostIncludingExtraNonQualifierSelectivity(CostEstimate cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost if we include an extra non-qualifier.- Specified by:
traceCostIncludingExtraNonQualifierSelectivity
in interfaceOptTrace
-
traceCostOfNoncoveringIndex
public void traceCostOfNoncoveringIndex(CostEstimate cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost of using a non-covering index.- Specified by:
traceCostOfNoncoveringIndex
in interfaceOptTrace
-
traceRememberingJoinStrategy
public void traceRememberingJoinStrategy(JoinStrategy joinStrategy, int tableNumber)
Description copied from interface:OptTrace
Say that we've found a new best join strategy for the table.- Specified by:
traceRememberingJoinStrategy
in interfaceOptTrace
-
traceRememberingBestAccessPathSubstring
public void traceRememberingBestAccessPathSubstring(AccessPath ap, int tableNumber)
Description copied from interface:OptTrace
Report the best access path for the table so far.- Specified by:
traceRememberingBestAccessPathSubstring
in interfaceOptTrace
-
traceRememberingBestSortAvoidanceAccessPathSubstring
public void traceRememberingBestSortAvoidanceAccessPathSubstring(AccessPath ap, int tableNumber)
Description copied from interface:OptTrace
Report the best sort-avoiding access path for this table so far.- Specified by:
traceRememberingBestSortAvoidanceAccessPathSubstring
in interfaceOptTrace
-
traceRememberingBestUnknownAccessPathSubstring
public void traceRememberingBestUnknownAccessPathSubstring(AccessPath ap, int tableNumber)
Description copied from interface:OptTrace
Report an optimizer failure, e.g., while optimizing an outer join- Specified by:
traceRememberingBestUnknownAccessPathSubstring
in interfaceOptTrace
-
traceCostOfConglomerateScan
public void traceCostOfConglomerateScan(int tableNumber, ConglomerateDescriptor cd, CostEstimate costEstimate, int numExtraFirstColumnPreds, double extraFirstColumnSelectivity, int numExtraStartStopPreds, double extraStartStopSelectivity, int startStopPredCount, double statStartStopSelectivity, int numExtraQualifiers, double extraQualifierSelectivity, int numExtraNonQualifiers, double extraNonQualifierSelectivity)
Description copied from interface:OptTrace
Report the cost of a conglomerate scan.- Specified by:
traceCostOfConglomerateScan
in interfaceOptTrace
-
traceCostIncludingCompositeSelectivityFromStats
public void traceCostIncludingCompositeSelectivityFromStats(CostEstimate cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost based on selectivities coming out of SYSSTATISTICS.- Specified by:
traceCostIncludingCompositeSelectivityFromStats
in interfaceOptTrace
-
traceCompositeSelectivityFromStatistics
public void traceCompositeSelectivityFromStatistics(double statCompositeSelectivity)
Description copied from interface:OptTrace
Report the selectivity calculated from SYSSTATISTICS.- Specified by:
traceCompositeSelectivityFromStatistics
in interfaceOptTrace
-
traceCostIncludingStatsForIndex
public void traceCostIncludingStatsForIndex(CostEstimate cost, int tableNumber)
Description copied from interface:OptTrace
Report the cost based on index statistics.- Specified by:
traceCostIncludingStatsForIndex
in interfaceOptTrace
-
printToWriter
public void printToWriter(java.io.PrintWriter out)
Description copied from interface:OptTrace
Print the trace so far.- Specified by:
printToWriter
in interfaceOptTrace
-
reportJoinOrder
private java.lang.String reportJoinOrder(java.lang.String prefix, boolean addJoinOrderNumber, int joinOrderNumber, int joinPosition, int[] joinOrder, JBitSet assignedTableMap)
-
reportConglomerateDescriptor
private java.lang.String reportConglomerateDescriptor(ConglomerateDescriptor cd)
-
reportCostForTable
private java.lang.String reportCostForTable(java.lang.Object cost, int tableNumber)
-
reportCostIncluding
private java.lang.String reportCostIncluding(java.lang.String selectivityType, CostEstimate cost, int tableNumber)
-
appendTraceString
private void appendTraceString(java.lang.String traceString)
Append a string to the optimizer trace
-
-