1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-19 21:43:15 +03:00

Do not use an automatic index on an outer loop that only runs once.

FossilOrigin-Name: 5957e793414ff80ed01a7a67e70c3fd096a3f6e0
This commit is contained in:
drh
2016-02-25 18:03:38 +00:00
parent c3489bbf77
commit 87eb919d05
4 changed files with 22 additions and 12 deletions

View File

@@ -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);