1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Fix a problem with estimating the number of rows visited by a query that uses a multi-column IN(SELECT...) constraint.

FossilOrigin-Name: 3c2f908f5b7312570cfa74afcf4252a857cb5237
This commit is contained in:
dan
2016-08-03 18:00:49 +00:00
parent 2c628ea9d9
commit 3d1fb1dd75
4 changed files with 48 additions and 11 deletions

View File

@@ -212,5 +212,33 @@ ifcapable stat4 {
}
}
#------------------------------------------------------------------------
do_execsql_test 5.0 {
CREATE TABLE d1(x, y);
CREATE TABLE d2(a, b, c);
CREATE INDEX d2ab ON d2(a, b);
CREATE INDEX d2c ON d2(c);
WITH i(i) AS (
VALUES(1) UNION ALL SELECT i+1 FROM i WHERE i<1000
)
INSERT INTO d2 SELECT i/3, i%3, i/3 FROM i;
ANALYZE;
}
do_eqp_test 5.1 {
SELECT * FROM d2 WHERE
(a, b) IN (SELECT x, y FROM d1) AND
(c) IN (SELECT y FROM d1)
} {
0 0 0 {SEARCH TABLE d2 USING INDEX d2ab (a=? AND b=?)}
0 0 0 {EXECUTE LIST SUBQUERY 1}
1 0 0 {SCAN TABLE d1}
0 0 0 {EXECUTE LIST SUBQUERY 2}
2 0 0 {SCAN TABLE d1}
}
finish_test