private ParsedResultAccumulator getBestCostPlanForEphemeralScans ( List < StmtEphemeralTableScan > scans ) { int nextPlanId = m_planSelector . m_planId ; boolean orderIsDeterministic = true ; boolean hasSignificantOffsetOrLimit = false ; String contentNonDeterminismMessage = null ; for ( StmtEphemeralTableScan scan : scans ) { if ( scan instanceof StmtSubqueryScan ) { nextPlanId = planForParsedSubquery ( ( StmtSubqueryScan ) scan , nextPlanId ) ; // If we can't plan this, then give up. if ( ( ( StmtSubqueryScan ) scan ) . getBestCostPlan ( ) == null ) { return null ; } } else if ( scan instanceof StmtCommonTableScan ) { nextPlanId = planForCommonTableQuery ( ( StmtCommonTableScan ) scan , nextPlanId ) ; if ( ( ( StmtCommonTableScan ) scan ) . getBestCostBasePlan ( ) == null ) { return null ; } } else { throw new PlanningErrorException ( "Unknown scan plan type." ) ; } orderIsDeterministic = scan . isOrderDeterministic ( orderIsDeterministic ) ; contentNonDeterminismMessage = scan . contentNonDeterminismMessage ( contentNonDeterminismMessage ) ; hasSignificantOffsetOrLimit = scan . hasSignificantOffsetOrLimit ( hasSignificantOffsetOrLimit ) ; } // need to reset plan id for the entire SQL m_planSelector . m_planId = nextPlanId ; return new ParsedResultAccumulator ( orderIsDeterministic , hasSignificantOffsetOrLimit , contentNonDeterminismMessage ) ; }
Generate best cost plans for a list of derived tables which we call FROM sub - queries and common table queries .