diff options
author | drh <drh@noemail.net> | 2014-10-21 18:16:21 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-10-21 18:16:21 +0000 |
commit | f7f2e84a9c7d24fae4ac6fa3d3722039f2101e9c (patch) | |
tree | 2b57ef2f5894e76f06ad3cc69a02631a639260df /src | |
parent | 1b131b7a7acc83c7bd1a5e7d0872c968d9e26489 (diff) | |
download | sqlite-f7f2e84a9c7d24fae4ac6fa3d3722039f2101e9c.tar.gz sqlite-f7f2e84a9c7d24fae4ac6fa3d3722039f2101e9c.zip |
Further tuning of the cost estimates for skip-scan loops, especially for cases
when skip-scan loops are in competition with regular loops.
FossilOrigin-Name: a27861c28c4791e51d797aa37e9cca806cb58775
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/where.c b/src/where.c index 7dfe0f02b..7f51d00c8 100644 --- a/src/where.c +++ b/src/where.c @@ -3994,7 +3994,9 @@ static void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){ if( (p->wsFlags & WHERE_INDEXED)==0 ) continue; if( whereLoopCheaperProperSubset(p, pTemplate) ){ /* Adjust pTemplate cost downward so that it is cheaper than its - ** subset p */ + ** subset p. Except, do not adjust the cost estimate downward for + ** a loop that skips more columns. */ + if( pTemplate->nSkip>p->nSkip ) continue; WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n", pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut-1)); pTemplate->rRun = p->rRun; @@ -4515,12 +4517,6 @@ static int whereLoopAddBtreeIndex( pNew->aLTerm[pNew->nLTerm++] = 0; pNew->wsFlags |= WHERE_SKIPSCAN; nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1]; - if( pTerm ){ - /* TUNING: When estimating skip-scan for a term that is also indexable, - ** 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. */ |