]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improvements to comments and debugging output.
authordrh <>
Wed, 29 May 2024 13:29:39 +0000 (13:29 +0000)
committerdrh <>
Wed, 29 May 2024 13:29:39 +0000 (13:29 +0000)
FossilOrigin-Name: 85164ee155e42809fe34e6c6b6fbe0a2baa9d616326a811173a0b0c8a885fcce

manifest
manifest.uuid
src/where.c

index ee9f8a9dec3d3f3c36ae7989bbdfd10a6b3a33f2..ac9d2b1802d36ad31ddfedbb6f5519165d9e2fb3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remember\sthe\samount\sof\sthe\sheuristic\scost\sadjustment\sassociated\swith\nstar\sschemas\sand\scompensate\swhen\scomputing\swhether\sor\snot\sto\suse\sBloom\nfilters.
-D 2024-05-29T10:40:53.540
+C Improvements\sto\scomments\sand\sdebugging\soutput.
+D 2024-05-29T13:29:39.023
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -840,7 +840,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89
 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452
 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2
-F src/where.c c0252858ec8a592a65de1055762bc4ec2d4c420264379ebf16a6f04c3f11db79
+F src/where.c 8b1e8f8db0d1be2e724c55dd2bd9d6df0d4084455fe5d7c08533ad56bc51f0e9
 F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65
 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8
 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd
@@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659
-R 09573248d7c98d9580312274c1891d0f
+P 21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2
+R 4cfa81a11fe00a9778c1578283da953a
 U drh
-Z f728ba1bce4df2db5c498d1d421f9c75
+Z b6f4b963a23017a1edcad5f2b0da308c
 # Remove this line to create a well-formed Fossil manifest.
index df7005455dd4076f747fc98c123625c35d29d491..1de88c6c8af7c265b5eb37be0b1911d1fa03405d 100644 (file)
@@ -1 +1 @@
-21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2
\ No newline at end of file
+85164ee155e42809fe34e6c6b6fbe0a2baa9d616326a811173a0b0c8a885fcce
\ No newline at end of file
index 6fc67ed2f9f1d912dfb9053a6e434529e58e70cb..5a5fd7b28f6e9f964ab8450a80bc0561b50571aa 100644 (file)
@@ -5252,10 +5252,14 @@ static LogEst whereSortingCost(
 ** Query planning is NP-hard.  We must limit the number of paths at
 ** each step of the solver search algorithm to avoid exponential behavior.
 **
-** The value returned is a tuning parameter.  Currently the value is
-** 12 for normal queries and 18 for "star-queries".  A star-query is
-** a query with large central table that is joined against three or
-** more smaller tables.  The central table is called the "fact" table.
+** The value returned is a tuning parameter.  Currently the value is:
+**
+**     18    for star queries
+**     12    otherwise
+**
+** For the purposes of SQLite, a star-query is defined as a query
+** with a large central table that is joined against four or more
+** smaller tables.  The central table is called the "fact" table.
 ** The smaller tables that get joined are "dimension tables".
 **
 ** SIDE EFFECT:
@@ -5264,7 +5268,9 @@ static LogEst whereSortingCost(
 ** fact table is reduced.  This heuristic helps keep fact tables in
 ** outer loops.  Without this heuristic, paths with fact tables in outer
 ** loops tend to get pruned by the mxChoice limit on the number of paths,
-** resulting in poor query plans.
+** resulting in poor query plans.  The total amount of heuristic cost
+** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment
+** for each WhereLoop is stored in its rStarDelta field.
 */
 static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){
   int nLoop = pWInfo->nLevel;    /* Number of terms in the join */
@@ -5289,6 +5295,14 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){
       }
       if( nDep<=3 ) continue;
       rDelta = 15*(nDep-3);
+#ifdef WHERETRACE_ENABLED /* 0x4 */
+      if( sqlite3WhereTrace&0x4 ){
+         SrcItem *pItem = pWInfo->pTabList->a + iLoop;
+         sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n",
+             pItem->zAlias ? pItem->zAlias : pItem->pTab->zName,
+             nDep, rDelta);
+      }
+#endif
       if( pWInfo->nOutStarDelta==0 ){
         for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
           pWLoop->rStarDelta = 0;
@@ -5342,6 +5356,8 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
 
   pParse = pWInfo->pParse;
   nLoop = pWInfo->nLevel;
+  WHERETRACE(0x002, ("---- begin solver.  (nRowEst=%d, nQueryLoop=%d)\n",
+                     nRowEst, pParse->nQueryLoop));
   /* TUNING: mxChoice is the maximum number of possible paths to preserve
   ** at each step.  Based on the number of loops in the FROM clause:
   **
@@ -5349,7 +5365,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
   **     -----      --------
   **       1            1            // the most common case
   **       2            5
-  **       3+        8*(N-2)
+  **       3+        12 or 18        // see computeMxChoice()
   */
   if( nLoop<=1 ){
     mxChoice = 1;
@@ -5359,8 +5375,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
     mxChoice = computeMxChoice(pWInfo, nRowEst);
   }
   assert( nLoop<=pWInfo->pTabList->nSrc );
-  WHERETRACE(0x002, ("---- begin solver.  (nRowEst=%d, nQueryLoop=%d)\n",
-                     nRowEst, pParse->nQueryLoop));
 
   /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this
   ** case the purpose of this call is to estimate the number of rows returned