diff options
author | drh <drh@noemail.net> | 2013-06-21 02:15:48 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-06-21 02:15:48 +0000 |
commit | bc71b1d4536ce7842f80010049c69f5fd2806b3b (patch) | |
tree | 1cff45b2fc2a82ffb4bf6d380ea9cb918844ace8 /src | |
parent | fd636c7541d0de19ce365fc9e483b88121531c2e (diff) | |
download | sqlite-bc71b1d4536ce7842f80010049c69f5fd2806b3b.tar.gz sqlite-bc71b1d4536ce7842f80010049c69f5fd2806b3b.zip |
Only eliminate inner loops of a JOIN if they are the RHS of a LEFT JOIN
and if they give no more than a single result. This appears to give correct
answers in all cases.
FossilOrigin-Name: d7a25cc79794817504ca1a4262008a68b2a4dece
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/where.c b/src/where.c index 18b4a3782..32fa61c7f 100644 --- a/src/where.c +++ b/src/where.c @@ -5794,16 +5794,16 @@ WhereInfo *sqlite3WhereBegin( if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy); while( pWInfo->nLevel>=2 ){ pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop; - if( ((wctrlFlags & WHERE_WANT_DISTINCT)!=0 - || (pLoop->wsFlags & WHERE_ONEROW)!=0) - && (tabUsed & pLoop->maskSelf)==0 + if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break; + if( (wctrlFlags & WHERE_WANT_DISTINCT)==0 + && (pLoop->wsFlags & WHERE_ONEROW)==0 ){ - WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId)); - pWInfo->nLevel--; - nTabList--; - }else{ break; } + if( (tabUsed & pLoop->maskSelf)!=0 ) break; + WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId)); + pWInfo->nLevel--; + nTabList--; } } WHERETRACE(0xffff,("*** Optimizer Finished ***\n")); |