diff options
author | drh <drh@noemail.net> | 2016-02-25 18:03:38 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-02-25 18:03:38 +0000 |
commit | 87eb919d05ba5487e3df2db6d0431d7b7b9c28a2 (patch) | |
tree | e7ceb1f33ce9b81bef6276b3b3a48ea5b4536e11 /src | |
parent | c3489bbf77cf206fdb7d6ffbffe2e3ce6b680c13 (diff) | |
download | sqlite-87eb919d05ba5487e3df2db6d0431d7b7b9c28a2.tar.gz sqlite-87eb919d05ba5487e3df2db6d0431d7b7b9c28a2.zip |
Do not use an automatic index on an outer loop that only runs once.
FossilOrigin-Name: 5957e793414ff80ed01a7a67e70c3fd096a3f6e0
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/where.c b/src/where.c index addd50674..3dc3c87a0 100644 --- a/src/where.c +++ b/src/where.c @@ -3585,6 +3585,14 @@ 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. */ + continue; + } /* At this point, pWLoop is a candidate to be the next loop. ** Compute its cost */ rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow); |