diff options
author | drh <drh@noemail.net> | 2018-06-09 14:13:46 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-06-09 14:13:46 +0000 |
commit | a46ba6cca5102ade4689faeb67a499d56360ebb7 (patch) | |
tree | a8d90b9a27d356f59d7ca32e3c83b3ab793693dd /src | |
parent | ccf6db5e6499f26c0463ed9840209c47c1d4a7a9 (diff) | |
download | sqlite-a46ba6cca5102ade4689faeb67a499d56360ebb7.tar.gz sqlite-a46ba6cca5102ade4689faeb67a499d56360ebb7.zip |
Improved comments an presentation for the recent IN operator decision
improvement.
FossilOrigin-Name: 31e480f68dfd887cfd9114f9f9fec53d751d3ecc27e36f55c0166b51b2fbb08c
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/where.c b/src/where.c index 56d37be01..0e47dbf7e 100644 --- a/src/where.c +++ b/src/where.c @@ -2451,7 +2451,6 @@ static int whereLoopAddBtreeIndex( if( eOp & WO_IN ){ Expr *pExpr = pTerm->pExpr; - LogEst M, logK; if( ExprHasProperty(pExpr, EP_xIsSelect) ){ /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */ int i; @@ -2472,6 +2471,7 @@ static int whereLoopAddBtreeIndex( ** changes "x IN (?)" into "x=?". */ } if( pProbe->hasStat1 ){ + LogEst M, logK, safetyMargin; /* Let: ** N = the total number of rows in the table ** K = the number of entries on the RHS of the IN operator @@ -2493,7 +2493,8 @@ static int whereLoopAddBtreeIndex( */ M = pProbe->aiRowLogEst[saved_nEq]; logK = estLog(nIn); - if( M + logK + 10 < nIn + rLogSize ){ + safetyMargin = 10; /* TUNING: extra weight for indexed IN */ + if( M + logK + safetyMargin < nIn + rLogSize ){ WHERETRACE(0x40, ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n", saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize)); |