1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Do not use a Bloom filter if any outer loop lacks STAT1 data, since without

STAT1 data, the query planner cannot make an accurate determination of
whether or not a Bloom filter will be useful.  This fixes the problem
reported by [forum:/forumpost/56de336385|forum post 56de336385].

FossilOrigin-Name: e6ab96bd0b9efc51fd703bf7e92b079943ad9a3b92183d434adc11fb7d238afb
This commit is contained in:
drh
2023-02-05 20:29:10 +00:00
parent 9ce8643676
commit 072f48e556
6 changed files with 59 additions and 22 deletions

View File

@ -66,5 +66,39 @@ do_execsql_test 1.5 {
AND t3.e=t1.b AND t3.f!='silly'
} {result}
finish_test
# 2023-02-05
# https://sqlite.org/forum/forumpost/56de336385
#
# Do not employ a Bloom filter if the table being filtered or any table
# wo the left of the table being filtered lacks STAT1 data, since we
# cannot make a good Bloom filter usefulness determination without STAT1
# data.
#
reset_db
do_execsql_test 2.0 {
CREATE TABLE objs(c INTEGER, s INTEGER, p INTEGER, o INTEGER);
CREATE UNIQUE INDEX objs_cspo ON objs(o,p,c,s);
ANALYZE;
DELETE FROM sqlite_stat1;
INSERT INTO sqlite_stat1 VALUES('objs','objs_cspo','520138 21 20 19 1');
ANALYZE sqlite_schema;
}
do_eqp_test 2.1 {
WITH RECURSIVE transit(x) AS (
SELECT s FROM objs WHERE p=9 AND o=32805
UNION
SELECT objs.s FROM objs, transit WHERE objs.p=9 AND objs.o=transit.x
)
SELECT x FROM transit;
} {
QUERY PLAN
|--CO-ROUTINE transit
| |--SETUP
| | `--SEARCH objs USING COVERING INDEX objs_cspo (o=? AND p=?)
| `--RECURSIVE STEP
| |--SCAN transit
| `--SEARCH objs USING COVERING INDEX objs_cspo (o=? AND p=?)
`--SCAN transit
}
finish_test

View File

@ -287,6 +287,8 @@ do_eqp_test 7.2 {
do_execsql_test 7.3 {
CREATE TABLE t3(x);
INSERT INTO t3(x) VALUES(1);
CREATE INDEX t3x ON t3(x);
CREATE TABLE t4(x, y, z);
CREATE INDEX t4xy ON t4(x, y);
@ -296,6 +298,8 @@ do_execsql_test 7.3 {
INSERT INTO t4 SELECT i/10, i, i FROM s;
ANALYZE;
UPDATE sqlite_stat1 SET stat='1000000 10 1' WHERE idx='t3x';
ANALYZE sqlite_schema;
}
do_eqp_test 7.4 {

View File

@ -258,7 +258,7 @@ do_execsql_test join8-7020 {
)
SELECT * FROM t0 FULL JOIN t4 ON t0.a=t4.d AND t4.z>0
ORDER BY coalesce(t0.a, t0.y+200, t4.d);
} {/.*BLOOM FILTER ON t2.*BLOOM FILTER ON t3.*BLOOM FILTER ON t4.*/}
} {/.*BLOOM FILTER ON t2.*BLOOM FILTER ON t3.*/}
# 2022-05-12 Difference with PG found (by Dan) while exploring
# https://sqlite.org/forum/forumpost/677a0ab93fcd9ccd