Class DefaultOptTrace

java.lang.Object
org.apache.derby.impl.sql.compile.DefaultOptTrace
All Implemented Interfaces:
OptTrace

public class DefaultOptTrace extends Object implements OptTrace
This is the default optimizer tracing logic for use when a custom tracer wasn't specified.
  • Field Details

  • Constructor Details

    • DefaultOptTrace

      public DefaultOptTrace()
      Make a DefaultOptTrace
  • Method Details

    • traceStartStatement

      public void traceStartStatement(String statementText)
      Description copied from interface: OptTrace
      Start the start of tracing a statement.
      Specified by:
      traceStartStatement in interface OptTrace
    • 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 interface OptTrace
    • traceEndQueryBlock

      public void traceEndQueryBlock()
      Description copied from interface: OptTrace
      End tracing the optimization of a query block.
      Specified by:
      traceEndQueryBlock in interface OptTrace
    • 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 interface OptTrace
    • traceVacuous

      public void traceVacuous()
      Description copied from interface: OptTrace
      Say that there's nothing to optimizer.
      Specified by:
      traceVacuous in interface OptTrace
    • traceCompleteJoinOrder

      public void traceCompleteJoinOrder()
      Description copied from interface: OptTrace
      Say that we have a complete join order.
      Specified by:
      traceCompleteJoinOrder in interface OptTrace
    • traceSortCost

      public void traceSortCost(CostEstimate sortCost, CostEstimate currentCost)
      Description copied from interface: OptTrace
      Report the sort cost.
      Specified by:
      traceSortCost in interface OptTrace
    • traceNoBestPlan

      public void traceNoBestPlan()
      Description copied from interface: OptTrace
      Say that we couldn't find a best plan.
      Specified by:
      traceNoBestPlan in interface OptTrace
    • traceModifyingAccessPaths

      public void traceModifyingAccessPaths(int optimizerID)
      Description copied from interface: OptTrace
      Say that we're modifying access paths.
      Specified by:
      traceModifyingAccessPaths in interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • traceIllegalUserJoinOrder

      public void traceIllegalUserJoinOrder()
      Description copied from interface: OptTrace
      Say that the user specified an impossible join order.
      Specified by:
      traceIllegalUserJoinOrder in interface OptTrace
    • traceUserJoinOrderOptimized

      public void traceUserJoinOrderOptimized()
      Description copied from interface: OptTrace
      Say that we have optimized the user-specified join order.
      Specified by:
      traceUserJoinOrderOptimized in interface OptTrace
    • 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 interface OptTrace
    • traceCostWithoutSortAvoidance

      public void traceCostWithoutSortAvoidance(CostEstimate currentCost)
      Description copied from interface: OptTrace
      Report the cost without a sort.
      Specified by:
      traceCostWithoutSortAvoidance in interface OptTrace
    • traceCostWithSortAvoidance

      public void traceCostWithSortAvoidance(CostEstimate currentSortAvoidanceCost)
      Description copied from interface: OptTrace
      Report the cost with sort avoidance.
      Specified by:
      traceCostWithSortAvoidance in interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • traceSortNeededForOrdering

      public void traceSortNeededForOrdering(int planType, RequiredRowOrdering requiredRowOrdering)
      Description copied from interface: OptTrace
      Report that this plan needs a sort
      Specified by:
      traceSortNeededForOrdering in interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • traceHashKeyColumns

      public void traceHashKeyColumns(int[] hashKeyColumns)
      Description copied from interface: OptTrace
      Report the columns being traced
      Specified by:
      traceHashKeyColumns in interface OptTrace
    • traceOptimizingJoinNode

      public void traceOptimizingJoinNode()
      Description copied from interface: OptTrace
      Say that we're starting to optimize a join node
      Specified by:
      traceOptimizingJoinNode in interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • traceAddingUnorderedOptimizable

      public void traceAddingUnorderedOptimizable(int predicateCount)
      Description copied from interface: OptTrace
      Say that we're adding an unordered optimizable.
      Specified by:
      traceAddingUnorderedOptimizable in interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • traceLookingForSpecifiedIndex

      public void traceLookingForSpecifiedIndex(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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • traceNextAccessPath

      public void traceNextAccessPath(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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • 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 interface OptTrace
    • traceCompositeSelectivityFromStatistics

      public void traceCompositeSelectivityFromStatistics(double statCompositeSelectivity)
      Description copied from interface: OptTrace
      Report the selectivity calculated from SYSSTATISTICS.
      Specified by:
      traceCompositeSelectivityFromStatistics in interface OptTrace
    • traceCostIncludingStatsForIndex

      public void traceCostIncludingStatsForIndex(CostEstimate cost, int tableNumber)
      Description copied from interface: OptTrace
      Report the cost based on index statistics.
      Specified by:
      traceCostIncludingStatsForIndex in interface OptTrace
    • printToWriter

      public void printToWriter(PrintWriter out)
      Description copied from interface: OptTrace
      Print the trace so far.
      Specified by:
      printToWriter in interface OptTrace
    • reportJoinOrder

      private String reportJoinOrder(String prefix, boolean addJoinOrderNumber, int joinOrderNumber, int joinPosition, int[] joinOrder, JBitSet assignedTableMap)
    • reportConglomerateDescriptor

      private String reportConglomerateDescriptor(ConglomerateDescriptor cd)
    • reportCostForTable

      private String reportCostForTable(Object cost, int tableNumber)
    • reportCostIncluding

      private String reportCostIncluding(String selectivityType, CostEstimate cost, int tableNumber)
    • appendTraceString

      private void appendTraceString(String traceString)
      Append a string to the optimizer trace