From 5a6f5ede8175ff253b85925e2728ea76f8c86c9f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Feb 2016 18:22:09 +0000 Subject: [PATCH] Improvement on the previous check-in: disallow automatic indexes for any loop that is expected to run less than twice. FossilOrigin-Name: aab53a21894ba51d325fd8f8f4bb4163ece74391 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 10 ++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index d9b4a87ec1..cb1fddd357 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\suse\san\sautomatic\sindex\son\san\souter\sloop\sthat\sonly\sruns\sonce. -D 2016-02-25T18:03:38.680 +C Improvement\son\sthe\sprevious\scheck-in:\s\sdisallow\sautomatic\sindexes\sfor\sany\nloop\sthat\sis\sexpected\sto\srun\sless\sthan\stwice. +D 2016-02-25T18:22:09.962 F Makefile.in 4e90dc1521879022aa9479268a4cd141d1771142 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 28fc4ee02333996d31b3602b39eeb8e609a89ce4 @@ -428,7 +428,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 10deb6b43887662691e5f53d10b3c171c401169b F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 07bf0330592acd2610d131aabe175cbada3e9710 +F src/where.c b21a2b3cee42e1db4f14c8fc5124f607e0c668c0 F src/whereInt.h 93297d56edd137b7ea004490690fb6e2ce028a34 F src/wherecode.c 39c1ef4598bedf1d66249334c74efd23ddd182ac F src/whereexpr.c fb87944b1254234e5bba671aaf6dee476241506a @@ -1429,7 +1429,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh a98af506df552f3b3c0d904f94e4cdc4e1a6d598 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d491745cab951e0de70f1f79b7640ea8aff6e8bb -R fb78c9128e17cc39ff6d4163eb8b91e3 +P 5957e793414ff80ed01a7a67e70c3fd096a3f6e0 +R 8a8e5a80c02a4dfa694df7d4a40dc042 U drh -Z b2631495aa69546c0305d417243ff503 +Z 5c10952be751c4b6279994eaa94bd734 diff --git a/manifest.uuid b/manifest.uuid index b4a5bbf637..27e8814012 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5957e793414ff80ed01a7a67e70c3fd096a3f6e0 \ No newline at end of file +aab53a21894ba51d325fd8f8f4bb4163ece74391 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 3dc3c87a09..a68dcf5bfc 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. -- 2.39.5