]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Further tuning of the cost estimates for skip-scan loops, especially for cases
authordrh <drh@noemail.net>
Tue, 21 Oct 2014 18:16:21 +0000 (18:16 +0000)
committerdrh <drh@noemail.net>
Tue, 21 Oct 2014 18:16:21 +0000 (18:16 +0000)
when skip-scan loops are in competition with regular loops.

FossilOrigin-Name: a27861c28c4791e51d797aa37e9cca806cb58775

manifest
manifest.uuid
src/where.c

index d708dca4f31e19e931bcef865eab441e5554fded..3daca49fdda36f3c494a3228c3b486adfd324a14 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improvements\sto\sthe\sWHERETRACE\sdebugging\slogic.
-D 2014-10-21T16:01:40.774
+C Further\stuning\sof\sthe\scost\sestimates\sfor\sskip-scan\sloops,\sespecially\sfor\scases\nwhen\sskip-scan\sloops\sare\sin\scompetition\swith\sregular\sloops.
+D 2014-10-21T18:16:21.388
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -302,7 +302,7 @@ F src/vtab.c cb0c194303fea276b48d7d4b6d970b5a96bde8de
 F src/wal.c 10e7de7ce90865a68153f001a61f1d985cd17983
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
-F src/where.c 45cb63cb1422d7e5a9229c297e978d294ae51e16
+F src/where.c 994b38c8697aad095878ef1e4860902df457427f
 F src/whereInt.h 4b459cdbfc9b01f5f27673a35f9967e4dea917e8
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -1205,7 +1205,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P f4b22a2620a5dc48949048c2ecbd226755d4b2c3
-R 59b7c6284af5e31186eaa6edb85f9e59
+P ec1e942f08548695ff02645b3f3cd6bb2516bc9a
+R 4f5d15d10f268e58d7c047d490bf8adc
 U drh
-Z 3eaff9a0b8f4f97b5dd119bc1e1acc8b
+Z 7d7f3f0271fe8b8df2863a2c22053442
index 838729f6987d7e1755c871ede7057075037ab112..52d4aafd994c789f2a179914c012decfee4023b3 100644 (file)
@@ -1 +1 @@
-ec1e942f08548695ff02645b3f3cd6bb2516bc9a
\ No newline at end of file
+a27861c28c4791e51d797aa37e9cca806cb58775
\ No newline at end of file
index 7dfe0f02bbf0b7b4689f49430f91a5fe6e47d443..7f51d00c87091db0456ff10bb3145336494b45ed 100644 (file)
@@ -3994,7 +3994,9 @@ static void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){
     if( (p->wsFlags & WHERE_INDEXED)==0 ) continue;
     if( whereLoopCheaperProperSubset(p, pTemplate) ){
       /* Adjust pTemplate cost downward so that it is cheaper than its 
-      ** subset p */
+      ** subset p.  Except, do not adjust the cost estimate downward for
+      ** a loop that skips more columns. */
+      if( pTemplate->nSkip>p->nSkip ) continue;
       WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n",
                        pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut-1));
       pTemplate->rRun = p->rRun;
@@ -4515,12 +4517,6 @@ static int whereLoopAddBtreeIndex(
     pNew->aLTerm[pNew->nLTerm++] = 0;
     pNew->wsFlags |= WHERE_SKIPSCAN;
     nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1];
-    if( pTerm ){
-      /* TUNING:  When estimating skip-scan for a term that is also indexable,
-      ** multiply the cost of the skip-scan by 2.0, to make it a little less
-      ** desirable than the regular index lookup. */
-      nIter += 10;  assert( 10==sqlite3LogEst(2) );
-    }
     pNew->nOut -= nIter;
     /* TUNING:  Because uncertainties in the estimates for skip-scan queries,
     ** add a 1.375 fudge factor to make skip-scan slightly less likely. */