]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem in the result set size estimation logic of the query planner -
authordrh <drh@noemail.net>
Thu, 15 Apr 2010 12:36:06 +0000 (12:36 +0000)
committerdrh <drh@noemail.net>
Thu, 15 Apr 2010 12:36:06 +0000 (12:36 +0000)
a problem introduced by the two previous changes.

FossilOrigin-Name: 33b1f584ef712625c4df8e2aefe895fa89f6a795

manifest
manifest.uuid
src/where.c

index d7f5bd5c6c4e0780ac1e7e9ce7d45d01d5870eac..1f60425958c9bb3122e2873bb28b7712073df9e8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Bring\sover\sthe\srecent\squery\splanner\senhancements\sfrom\sthe\strunk.
-D 2010-04-15T02:37:11
+C Fix\sa\sproblem\sin\sthe\sresult\sset\ssize\sestimation\slogic\sof\sthe\squery\splanner\s-\s\na\sproblem\sintroduced\sby\sthe\stwo\sprevious\schanges.
+D 2010-04-15T12:36:07
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -227,7 +227,7 @@ F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
-F src/where.c 74ff6f0d96b3190f8abe2ceaa09858441749e8ff
+F src/where.c faadd9c2bf08868e5135192b44e0d753e363a885
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
@@ -807,14 +807,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P c18077f2465fc34830f11c9832e76be5746eaeea defaf0d99a807027f8883bf821b6482025f9f54e
-R 5f5abc6d19fbeba7fb34263a5662faa7
+P 82969f27e5ea843cb379666d8a02e4a3fddc03b2
+R 351077133ab404e2e491a33b905acb9d
 U drh
-Z 9dfe9b346dd22ca03d0d17a2ddbb8a3c
+Z 2a5a2f50be97ee24579935014cd533e4
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFLxnvaoxKgR168RlERAkpHAJ9umCCf7Sfy2xa1T3mJ1bqzrPY7tgCgjEA2
-oN5S7m+hWn0GMbvXKOIs1cY=
-=ADT1
+iD8DBQFLxwg6oxKgR168RlERAn1aAJ96LitidK5axyWqFd8S2OYRbsKviACdE9xg
+/OWvfn581zFJtn2LS8VJjjA=
+=qS5Y
 -----END PGP SIGNATURE-----
index 232556f3c5adcc5eb51b0fc062a7354e019ccb3d..a4611cbd357b440fcd4f2fe750ab849dd4c5c1a9 100644 (file)
@@ -1 +1 @@
-82969f27e5ea843cb379666d8a02e4a3fddc03b2
\ No newline at end of file
+33b1f584ef712625c4df8e2aefe895fa89f6a795
\ No newline at end of file
index 77ecdfef4603346428e89d90b65790ed1907f109..e13ca51d030b542c946f926cb74b22303d957112 100644 (file)
@@ -2737,12 +2737,23 @@ static void bestBtreeIndex(
     ** matters if the current index is the least costly, so do not bother
     ** with this step if we already know this index will not be chosen.
     ** Also, never reduce the output row count below 2 using this step.
+    **
+    ** Do not reduce the output row count if pSrc is the only table that
+    ** is notReady; if notReady is a power of two.  This will be the case
+    ** when the main sqlite3WhereBegin() loop is scanning for a table with
+    ** and "optimal" index, and on such a scan the output row count
+    ** reduction is not valid because it does not update the "pCost->used"
+    ** bitmap.  The notReady bitmap will also be a power of two when we
+    ** are scanning for the last table in a 64-way join.  We are willing
+    ** to bypass this optimization in that corner case.
     */
-    if( nRow>2 && cost<=pCost->rCost ){
-      int k;
-      int nSkipEq = nEq;
-      int nSkipRange = nBound;
-      Bitmask thisTab = getMask(pWC->pMaskSet, iCur);
+    if( nRow>2 && cost<=pCost->rCost && (notReady & (notReady-1))!=0 ){
+      int k;                       /* Loop counter */
+      int nSkipEq = nEq;           /* Number of == constraints to skip */
+      int nSkipRange = nBound;     /* Number of < constraints to skip */
+      Bitmask thisTab;             /* Bitmap for pSrc */
+
+      thisTab = getMask(pWC->pMaskSet, iCur);
       for(pTerm=pWC->a, k=pWC->nTerm; nRow>2 && k; k--, pTerm++){
         if( pTerm->wtFlags & TERM_VIRTUAL ) continue;
         if( (pTerm->prereqAll & notReady)!=thisTab ) continue;