diff options
author | unknown <igor@rurik.mysql.com> | 2006-05-11 19:47:00 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2006-05-11 19:47:00 -0700 |
commit | 5c6d923f3095f5eca3abaa5277350bec90e4970c (patch) | |
tree | 8cb368f539664f3d5f04cbd5173b20360e61f63a /mysql-test/t | |
parent | 60bb69aa04a1795d6c1156e9814ce446662a8967 (diff) | |
download | mariadb-git-5c6d923f3095f5eca3abaa5277350bec90e4970c.tar.gz |
Added a test case for bug #18940:in 5.0 the optimizer chose
a worse execution plan than in 4.1 for some queries.
It happened due the fact that at some conditions the
optimizer always preferred range or full index scan access
methods to lookup access methods even when the latter were much
cheaper.
The problem was not observed in 4.1 for the reported query
because the WHERE condition was not of a form that could
cause the problem.
Equality propagation introduced on 5.0 added an extra
predicate and changed the WHERE condition. The new condition
provoked the optimizer to make a bad choice.
The problem was fixed by the patch for bug 17379.
mysql-test/r/select.result:
Added a test case for bug #18940.
The problem was fixed by the patch for bug 17379.
mysql-test/t/select.test:
Added a test case for bug #18940.
The problem was fixed by the patch for bug 17379.
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/select.test | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 033350d138a..4b6ae921b9b 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2899,3 +2899,24 @@ select 'In next EXPLAIN, B.rows must be exactly 10:' Z; explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5 and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5); drop table t1, t2; + +# +#Bug #18940: selection of optimal execution plan caused by equality +# propagation (the bug was fixed by the patch for bug #17379) + +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), + (3,1), (5,1), (8,9), (2,2), (0,9); + +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES + (1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), + (5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), + (0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); + +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; + +DROP TABLE t1, t2; |