diff options
Diffstat (limited to 'src/where.c')
-rw-r--r-- | src/where.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/where.c b/src/where.c index a68dcf5bf..ed90f6144 100644 --- a/src/where.c +++ b/src/where.c @@ -1561,7 +1561,8 @@ static int whereEqualScanEst( pBuilder->nRecValid = nEq; whereKeyStats(pParse, p, pRec, 0, a); - WHERETRACE(0x10,("equality scan regions: %d\n", (int)a[1])); + WHERETRACE(0x10,("equality scan regions %s(%d): %d\n", + p->zName, nEq-1, (int)a[1])); *pnRow = a[1]; return rc; @@ -2897,13 +2898,6 @@ static int whereLoopAddVirtual( testcase( iTerm==16 ); if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm; if( (pTerm->eOperator & WO_IN)!=0 ){ - if( pUsage[i].omit==0 ){ - /* Do not attempt to use an IN constraint if the virtual table - ** says that the equivalent EQ constraint cannot be safely omitted. - ** If we do attempt to use such a constraint, some rows might be - ** repeated in the output. */ - break; - } /* A virtual table that is constrained by an IN clause may not ** consume the ORDER BY clause because (1) the order of IN terms ** is not necessarily related to the order of output terms and @@ -3463,9 +3457,8 @@ static LogEst whereSortingCost( /* Multiple by log(M) where M is the number of output rows. ** Use the LIMIT for M if it is smaller */ - if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 ){ - LogEst m = sqlite3LogEst(pWInfo->iLimit); - if( m<nRow ) nRow = m; + if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){ + nRow = pWInfo->iLimit; } rSortCost += estLog(nRow); return rSortCost; |