1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Improved detection of when the LEFT JOIN strength reduction optimization

can be applied.

FossilOrigin-Name: f544a8e47cdd5ad7233887a558489983f4f305a39391ff463c43e2e4157da087
This commit is contained in:
drh
2023-05-31 18:35:12 +00:00
parent d3b54d624f
commit 29e70da4a4
4 changed files with 39 additions and 19 deletions

View File

@ -302,14 +302,34 @@ do_execsql_test 7.3 {
ANALYZE sqlite_schema;
}
# If both sides of the OR reference the right-hand side of the LEFT JOIN
# then simplify the LEFT JOIN.
#
do_eqp_test 7.4 {
SELECT * FROM t3 LEFT JOIN t4 ON (t4.x = t3.x) WHERE (t4.y = ? OR t4.z = ?);
} {
QUERY PLAN
|--SCAN t4
`--SEARCH t3 USING COVERING INDEX t3x (x=?)
}
# If only one side of the OR references the right-hand side of the LEFT JOIN
# then do not do the simplification
#
do_eqp_test 7.4b {
SELECT * FROM t3 LEFT JOIN t4 ON (t4.x = t3.x) WHERE (t4.y = ? OR t3.x = ?);
} {
QUERY PLAN
|--SCAN t3
`--SEARCH t4 USING INDEX t4xz (x=?) LEFT-JOIN
}
do_eqp_test 7.4b {
do_eqp_test 7.4c {
SELECT * FROM t3 LEFT JOIN t4 ON (t4.x = t3.x) WHERE (t3.x = ? OR t4.z = ?);
} {
QUERY PLAN
|--SCAN t3
`--SEARCH t4 USING INDEX t4xz (x=?) LEFT-JOIN
}
do_eqp_test 7.4d {
SELECT * FROM t3 CROSS JOIN t4 ON (t4.x = t3.x) WHERE (+t4.y = ? OR t4.z = ?);
} {
QUERY PLAN