diff options
author | drh <drh@noemail.net> | 2016-02-25 18:22:09 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-02-25 18:22:09 +0000 |
commit | 5a6f5ede8175ff253b85925e2728ea76f8c86c9f (patch) | |
tree | 5434cff7cd63864fa71878b3adc0ec631e6e9284 /src | |
parent | 87eb919d05ba5487e3df2db6d0431d7b7b9c28a2 (diff) | |
download | sqlite-5a6f5ede8175ff253b85925e2728ea76f8c86c9f.tar.gz sqlite-5a6f5ede8175ff253b85925e2728ea76f8c86c9f.zip |
Improvement on the previous check-in: disallow automatic indexes for any
loop that is expected to run less than twice.
FossilOrigin-Name: aab53a21894ba51d325fd8f8f4bb4163ece74391
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/where.c b/src/where.c index 3dc3c87a0..a68dcf5bf 100644 --- a/src/where.c +++ b/src/where.c @@ -3585,12 +3585,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue; if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue; - if( iLoop==0 - && (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 - && pParse->nQueryLoop==0 - ){ - /* Never put an automatic index in the outer loop if the query - ** is only being run once. */ + if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<10 ){ + /* Do not use an automatic index if the this loop is expected + ** to run less than 2 times. */ + assert( 10==sqlite3LogEst(2) ); continue; } /* At this point, pWLoop is a candidate to be the next loop. |