Index: src/where.c ================================================================== --- src/where.c +++ src/where.c @@ -4742,20 +4742,10 @@ whereClauseClear(pWInfo->pWC); sqlite3DbFree(db, pWInfo); } } -/* -** Return TRUE if the wsFlags indicate that a full table scan (or a -** full scan of a covering index) is indicated. -*/ -static int isFullscan(unsigned wsFlags){ - if( wsFlags & WHERE_COVER_SCAN ) return 1; - if( (wsFlags & WHERE_NOT_FULLSCAN)==0 ) return 1; - return 0; -} - /* ** Generate the beginning of the loop used for WHERE clause processing. ** The return value is a pointer to an opaque structure that contains ** information needed to terminate the loop. Later, the calling routine @@ -5130,12 +5120,12 @@ ** ** (1) The table must not depend on other tables that have not ** yet run. (In other words, it must not depend on tables ** in inner loops.) ** - ** (2) A full-table-scan plan cannot supercede indexed plan unless - ** the full-table-scan is an "optimal" plan as defined above. + ** (2) (This rule was removed on 2012-11-09. The scaling of the + ** cost using the optimal scan cost made this rule obsolete.) ** ** (3) All tables have an INDEXED BY clause or this table lacks an ** INDEXED BY clause or this table uses the specific ** index specified by its INDEXED BY clause. This rule ensures ** that a best-so-far is always selected even if an impossible @@ -5146,13 +5136,10 @@ ** ** (4) The plan cost must be lower than prior plans, where "cost" ** is defined by the compareCost() function above. */ if( (sWBI.cost.used&sWBI.notValid)==0 /* (1) */ - && (bestJ<0 || (notIndexed&m)!=0 /* (2) */ - || isFullscan(bestPlan.plan.wsFlags) - || !isFullscan(sWBI.cost.plan.wsFlags)) && (nUnconstrained==0 || sWBI.pSrc->pIndex==0 /* (3) */ || NEVER((sWBI.cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0)) && (bestJ<0 || compareCost(&sWBI.cost, &bestPlan)) /* (4) */ ){ WHERETRACE((" === table %d (%s) is best so far\n"