From: drh <> Date: Tue, 7 Dec 2021 22:37:50 +0000 (+0000) Subject: Do not generate a Bloom filter if it cannot be used prior to the next seek, X-Git-Tag: version-3.38.0~186^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=761d64b73bc7ceb5ef60d956b6e1b78c1997082d;p=thirdparty%2Fsqlite.git Do not generate a Bloom filter if it cannot be used prior to the next seek, as that leads to a misleading EXPLAIN QUERY PLAN. FossilOrigin-Name: 2739ed5192058fbcc816ecbc252be687efc606e038bfcd6cf71194a3f4f5684e --- diff --git a/manifest b/manifest index 6a4298ce44..78850cff06 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sEXPLAIN\sQUERY\sPLAN\soutput\sfor\sBloom\sfilters. -D 2021-12-06T23:07:59.482 +C Do\snot\sgenerate\sa\sBloom\sfilter\sif\sit\scannot\sbe\sused\sprior\sto\sthe\snext\sseek,\nas\sthat\sleads\sto\sa\smisleading\sEXPLAIN\sQUERY\sPLAN. +D 2021-12-07T22:37:50.686 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -638,7 +638,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c ed0398a7adf02c31e34aada42cc86c58f413a7afe5f741a5d373ad087abde028 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b -F src/where.c 21bd1078837afb127827243d7ad549a4b47022ffaa43c5baa74dcac7f89809a7 +F src/where.c 328e5c6f5a91f8c1e36417159cc93ea180700ae97726f934f69e68c8c60030b5 F src/whereInt.h 5c6601d6d0b7b8936482506d2d835981cc6efcd8e106a829893a27a14cfb10b8 F src/wherecode.c f82a322a8849a0290587d968f5c1c71b0d5018e078f43ea732a4cdbf837ed42b F src/whereexpr.c 19394cb463003e9cc9305730b1508b8817a22bb7247170d81234b691a7f05b89 @@ -1934,7 +1934,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 24ba535d200fc8a99dd8e66c6d100b5f6ae442098bafb152008429398eefe3e7 -R 7eae2a1d2a9d2b173d70c0467bdac4ba +P 00070e1fff6aec3d7c7b121f2b02bbca38a1664aca9afc3fb7e293f07fd1704f +R 6ef1a6c68af918fb5dc855e869b3769c U drh -Z 477e7fdac36f7f761dc02a6457a5f233 +Z 7a26146d090468562610338a13462117 diff --git a/manifest.uuid b/manifest.uuid index a54777d56d..f1d3a5f29a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00070e1fff6aec3d7c7b121f2b02bbca38a1664aca9afc3fb7e293f07fd1704f \ No newline at end of file +2739ed5192058fbcc816ecbc252be687efc606e038bfcd6cf71194a3f4f5684e \ No newline at end of file diff --git a/src/where.c b/src/where.c index e7246b1040..1eb9f36017 100644 --- a/src/where.c +++ b/src/where.c @@ -988,7 +988,8 @@ end_auto_index_create: static SQLITE_NOINLINE void constructBloomFilter( WhereInfo *pWInfo, /* The WHERE clause */ int iLevel, /* Index in pWInfo->a[] that is pLevel */ - WhereLevel *pLevel /* Make a Bloom filter for this FROM term */ + WhereLevel *pLevel, /* Make a Bloom filter for this FROM term */ + Bitmask notReady /* Loops that are not ready */ ){ int addrOnce; /* Address of opening OP_Once */ int addrTop; /* Address of OP_Rewind */ @@ -1076,7 +1077,9 @@ static SQLITE_NOINLINE void constructBloomFilter( iLevel++; pLevel = &pWInfo->a[iLevel]; pLoop = pLevel->pWLoop; - if( pLoop && pLoop->wsFlags & WHERE_BLOOMFILTER ) break; + if( pLoop==0 ) continue; + if( pLoop->prereq & notReady ) continue; + if( pLoop->wsFlags & WHERE_BLOOMFILTER ) break; } }while( iLevel < pWInfo->nLevel ); sqlite3VdbeJumpHere(v, addrOnce); @@ -5594,7 +5597,7 @@ WhereInfo *sqlite3WhereBegin( &pTabList->a[pLevel->iFrom], notReady, pLevel); #endif }else{ - constructBloomFilter(pWInfo, ii, pLevel); + constructBloomFilter(pWInfo, ii, pLevel, notReady); } if( db->mallocFailed ) goto whereBeginError; }