]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remember the amount of the heuristic cost adjustment associated with
authordrh <>
Wed, 29 May 2024 10:40:53 +0000 (10:40 +0000)
committerdrh <>
Wed, 29 May 2024 10:40:53 +0000 (10:40 +0000)
star schemas and compensate when computing whether or not to use Bloom
filters.

FossilOrigin-Name: 21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2

manifest
manifest.uuid
src/where.c
src/whereInt.h

index 780408aedfa675d0b289314116bec2b7ef81cc4d..ee9f8a9dec3d3f3c36ae7989bbdfd10a6b3a33f2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\stypos\sin\sthe\sstar-schema\stest\scases.
-D 2024-05-29T09:53:19.834
+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
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -840,8 +840,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89
 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452
 F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2
-F src/where.c 4b777f3c20be01c9849f651a99f187a83300effd20ed8079e16e6498ca99a1f6
-F src/whereInt.h aff769fab5e21f8da96d4588f49204fa341f5d0f762ce965826dcf4f57c5a9d1
+F src/where.c c0252858ec8a592a65de1055762bc4ec2d4c420264379ebf16a6f04c3f11db79
+F src/whereInt.h 002adc3aa2cc10733b9b27958fdbe893987cd989fab25a9853941c1f9b9b0a65
 F src/wherecode.c d5184620bcb5265d59072cb66e1386bfe0331a9ce7614286f9ab79a4fcd00fb8
 F src/whereexpr.c 67d15caf88a1a9528283d68ff578e024cf9fe810b517bb0343e5aaf695ad97dd
 F src/window.c 5d95122dd330bfaebd732358c8ef067c5a9394a53ac249470d611d0ce2c52be2
@@ -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 a98be0f548f277fab8f38a2dec6ddcbe7a7fff27856ba19e76ad8c5641894b7b
-R aa7180ddabb7c050acee0a4bf1b87870
+P 4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659
+R 09573248d7c98d9580312274c1891d0f
 U drh
-Z 802df12468bb23a40911cf024be4e536
+Z f728ba1bce4df2db5c498d1d421f9c75
 # Remove this line to create a well-formed Fossil manifest.
index 8880d8ddd0a049f824ad5a5559ff9493e8c9044b..df7005455dd4076f747fc98c123625c35d29d491 100644 (file)
@@ -1 +1 @@
-4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659
\ No newline at end of file
+21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2
\ No newline at end of file
index 15ca06237f6452fa805c6f2190a7481b3777c4e5..6fc67ed2f9f1d912dfb9053a6e434529e58e70cb 100644 (file)
@@ -5277,10 +5277,10 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){
     Bitmask m;                /* Bitmask for current loop */
     assert( pWInfo->nOutStarDelta==0 );
     for(iLoop=0, m=1; iLoop<nLoop; iLoop++, m<<=1){
-      int nDep = 0;
-      WhereLoop *pWLoop;
-      LogEst rDelta;
-      Bitmask mSeen = 0;
+      WhereLoop *pWLoop;        /* For looping over WhereLoops */
+      int nDep = 0;             /* Number of dimension tables */
+      LogEst rDelta;            /* Heuristic cost adjustment */
+      Bitmask mSeen = 0;        /* Mask of dimension tables */
       for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
         if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){
           nDep++;
@@ -5289,11 +5289,17 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){
       }
       if( nDep<=3 ) continue;
       rDelta = 15*(nDep-3);
+      if( pWInfo->nOutStarDelta==0 ){
+        for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
+          pWLoop->rStarDelta = 0;
+        }
+      }
       pWInfo->nOutStarDelta += rDelta;
       for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
         if( pWLoop->maskSelf==m ){
           pWLoop->rRun -= rDelta;
           pWLoop->nOut -= rDelta;
+          pWLoop->rStarDelta = rDelta;
         }
       }
     }      
@@ -6104,6 +6110,7 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
       }
     }
     nSearch += pLoop->nOut;
+    if( pWInfo->nOutStarDelta ) nSearch += pLoop->rStarDelta;
   }
 }
 
index fc9b32a36d995ccf64477c8ec1d27ed1997513c2..d3226e0868d3a9060fabb8185553a1a4dfcb3157 100644 (file)
@@ -160,6 +160,8 @@ struct WhereLoop {
   /**** whereLoopXfer() copies fields above ***********************/
 # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)
   u16 nLSlot;           /* Number of slots allocated for aLTerm[] */
+  LogEst rStarDelta;    /* Cost delta due to star-schema heuristic.  Not
+                        ** initialized unless pWInfo->nOutStarDelta>0 */
   WhereTerm **aLTerm;   /* WhereTerms used */
   WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
   WhereTerm *aLTermSpace[3];  /* Initial aLTerm[] space */