]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Further tweaks to the query planner logic in preparation for adding
authordrh <drh@noemail.net>
Thu, 27 Sep 2012 12:05:09 +0000 (12:05 +0000)
committerdrh <drh@noemail.net>
Thu, 27 Sep 2012 12:05:09 +0000 (12:05 +0000)
ORDER BY opt-out for joins.

FossilOrigin-Name: 53efc10af990d3f293551f3cd8ef2f8be2d9d716

manifest
manifest.uuid
src/where.c

index b047d69df4e4a64acf667fb44209f80d837dbf1e..5f591e9ff6f1de68ec794474d29c466dba905151 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Further\srefactoring\sof\sthe\sORDER\sBY\srelated\squery-planning\slogic\sin\sorder\nto\smake\sit\seasier\sto\sextend\sto\ssupport\soptimizing\sout\sORDER\sBY\son\sjoins.\nNo\sactual\sbehavior\schanges,\syet.
-D 2012-09-26T23:17:01.276
+C Further\stweaks\sto\sthe\squery\splanner\slogic\sin\spreparation\sfor\sadding\nORDER\sBY\sopt-out\sfor\sjoins.
+D 2012-09-27T12:05:09.522
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -249,7 +249,7 @@ F src/vtab.c d8020c0a0e8ccc490ca449d7e665311b6e9f3ba9
 F src/wal.c 5acb3e7bbd31f10ba39acad9ce6b399055337a9d
 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b
-F src/where.c 59b852d51d86fd3bf5935067994114bf88affbef
+F src/where.c 67438c6192c5f777139e7abb642a9186a21a718d
 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/aggnested.test 0be144b453e0622a085fae8665c32f5676708e00
@@ -1016,7 +1016,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
-P 4226e51ff837f0ffe16355491a655d919d13488e
-R 82e96539fb8ddcfab6615c786a34a1ea
+P 96496ddae12a239b30a1fc997fbea43e3a75bfe7
+R 57ad7fba1d5db0bb9191afb65acee747
 U drh
-Z e46432508017f3912d4e7cd1bd8daf63
+Z 58fdbd300662a0c1ec2665b77df5f795
index 52ca9470eed709476419d103edf7db1cbc8886cf..2e377696fce68789b546a12118eb9896e422bb39 100644 (file)
@@ -1 +1 @@
-96496ddae12a239b30a1fc997fbea43e3a75bfe7
\ No newline at end of file
+53efc10af990d3f293551f3cd8ef2f8be2d9d716
\ No newline at end of file
index 05f5bcc4140c8eb7043cc2281efa0f58c702e819..0405860c9a9d3bdd7cd61ff69a3cd0ba65bc3685 100644 (file)
@@ -3067,13 +3067,8 @@ static void bestBtreeIndex(WhereBestIdx *p){
 #endif
 
     nOrderBy = p->pOrderBy ? p->pOrderBy->nExpr : 0;
-    if( (p->i) > 0 ){
-      bSort = 0;
-      bDist = 0;
-    }else{
-      bSort = p->pOrderBy!=0;
-      bDist = p->pDistinct!=0;
-    }
+    bSort = nOrderBy>0 && (p->i==0 || p->aLevel[p->i-1].plan.nOBSat<nOrderBy);
+    bDist = p->i==0 && p->pDistinct!=0;
 
     /* Determine the values of nEq and nInMul */
     for(nEq=nOrdered=0; nEq<pProbe->nColumn; nEq++){
@@ -3369,8 +3364,8 @@ static void bestBtreeIndex(WhereBestIdx *p){
 
     WHERETRACE((
       "%s(%s): nEq=%d nInMul=%d rangeDiv=%d bSort=%d bLookup=%d wsFlags=0x%x\n"
-      "         notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f used=0x%llx\n"
-      "         nOrdered=%d nOBSat=%d\n",
+      "         notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f\n"
+      "         used=0x%llx nOrdered=%d nOBSat=%d\n",
       pSrc->pTab->zName, (pIdx ? pIdx->zName : "ipk"), 
       nEq, nInMul, (int)rangeDiv, bSort, bLookup, wsFlags,
       p->notReady, log10N, nRow, cost, used, nOrdered, nOBSat
@@ -5024,8 +5019,9 @@ WhereInfo *sqlite3WhereBegin(
                  && sWBI.cost.plan.nRow<bestPlan.plan.nRow))
         ){
           WHERETRACE(("=== table %d is best so far"
-                      " with cost=%g and nRow=%g\n",
-                      j, sWBI.cost.rCost, sWBI.cost.plan.nRow));
+                      " with cost=%.1f, nRow=%.1f, nOBSat=%d\n",
+                      j, sWBI.cost.rCost, sWBI.cost.plan.nRow,
+                      sWBI.cost.plan.nOBSat));
           bestPlan = sWBI.cost;
           bestJ = j;
         }
@@ -5035,8 +5031,9 @@ WhereInfo *sqlite3WhereBegin(
     assert( bestJ>=0 );
     assert( sWBI.notValid & getMask(pMaskSet, pTabList->a[bestJ].iCursor) );
     WHERETRACE(("*** Optimizer selects table %d for loop %d"
-                " with cost=%g and nRow=%g\n",
-                bestJ, pLevel-pWInfo->a, bestPlan.rCost, bestPlan.plan.nRow));
+                " with cost=%.1f, nRow=%.1f, nOBSat=%d\n",
+                bestJ, pLevel-pWInfo->a, bestPlan.rCost, bestPlan.plan.nRow,
+                bestPlan.plan.nOBSat));
     if( (bestPlan.plan.wsFlags & WHERE_ORDERBY)!=0 ){
       pWInfo->nOBSat = pOrderBy->nExpr;
     }