aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-09-23 01:40:59 +0000
committerdrh <drh@noemail.net>2014-09-23 01:40:59 +0000
commit14f0e2128ac9cbbe5e1e871372911e3df447df4f (patch)
tree3c7a787a8c6407a2a6f44b0b4ee918c2a3a341bc /src
parenta4bb5b0726772476cdf36b4a0182e27a73fab557 (diff)
downloadsqlite-14f0e2128ac9cbbe5e1e871372911e3df447df4f.tar.gz
sqlite-14f0e2128ac9cbbe5e1e871372911e3df447df4f.zip
Adjust skip-scan cost estimates slightly so that a full table scan is
preferred over a skip-scan to a column with only two distinct values. FossilOrigin-Name: ae9a42b268ad3f7d21a5813bb931e795c6917014
Diffstat (limited to 'src')
-rw-r--r--src/where.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/where.c b/src/where.c
index d1862b499..40f95acc4 100644
--- a/src/where.c
+++ b/src/where.c
@@ -4359,11 +4359,14 @@ static int whereLoopAddBtreeIndex(
nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1];
if( pTerm ){
/* TUNING: When estimating skip-scan for a term that is also indexable,
- ** increase the cost of the skip-scan by 2x, to make it a little less
+ ** multiply the cost of the skip-scan by 2.0, to make it a little less
** desirable than the regular index lookup. */
nIter += 10; assert( 10==sqlite3LogEst(2) );
}
pNew->nOut -= nIter;
+ /* TUNING: Because uncertainties in the estimates for skip-scan queries,
+ ** add a 1.375 fudge factor to make skip-scan slightly less likely. */
+ nIter += 5;
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);
pNew->nOut = saved_nOut;
pNew->u.btree.nEq = saved_nEq;