From: drh <> Date: Wed, 29 May 2024 10:40:53 +0000 (+0000) Subject: Remember the amount of the heuristic cost adjustment associated with X-Git-Tag: version-3.47.0~370^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=54bfc9435fc8d1d6e70e349b2442539e839cfc6b;p=thirdparty%2Fsqlite.git Remember the amount of the heuristic cost adjustment associated with star schemas and compensate when computing whether or not to use Bloom filters. FossilOrigin-Name: 21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2 --- diff --git a/manifest b/manifest index 780408aedf..ee9f8a9dec 100644 --- 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. diff --git a/manifest.uuid b/manifest.uuid index 8880d8ddd0..df7005455d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4080937353985eb391f70a3a7fae890823cf01d19c52939e343fb2504f3f8659 \ No newline at end of file +21daf2463ef70e6b5dc73ba5bf62b3d2fb504e9189f645ac74b513d3d8b979c2 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 15ca06237f..6fc67ed2f9 100644 --- a/src/where.c +++ b/src/where.c @@ -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; iLooppLoops; 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; } } diff --git a/src/whereInt.h b/src/whereInt.h index fc9b32a36d..d3226e0868 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -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 */