Class DefaultOptTrace

  • All Implemented Interfaces:
    OptTrace

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

      • _buffer

        private java.lang.StringBuilder _buffer
    • Constructor Detail

      • DefaultOptTrace

        public DefaultOptTrace()
        Make a DefaultOptTrace
    • 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 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
      • 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
      • 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
      • 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
      • 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
      • 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 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
      • 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 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
      • 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
      • traceCompositeSelectivityFromStatistics

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

        public void printToWriter​(java.io.PrintWriter out)
        Description copied from interface: OptTrace
        Print the trace so far.
        Specified by:
        printToWriter in interface OptTrace
      • 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