Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
11.1(EOL)
-
None
-
None
Description
In the case below, the plan for SELECT and DELETE is expected to be the same, but it is not
create table t1 (c1 integer, c2 integer, c3 integer); |
|
|
insert into t1(c1,c2,c3) |
values (1,1,1),(1,2,2),(1,3,3), |
(2,1,4),(2,2,5),(2,3,6),
|
(2,4,7),(2,5,8);
|
insert into t1 select c1+10,c2,c3+10 from t1; |
insert into t1 select c1+20,c2+1,c3+20 from t1; |
|
|
create view v1 as select * from t1 where c2=2; |
|
|
analyze table t1 persistent for all; |
|
|
let $c = v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3) |
and c1 = 2 |
and exists (select 'X' from v1 a where a.c1 = v1.c1); |
|
|
eval explain select * from v1 where $c; |
eval explain delete from v1 where $c; |
|
|
drop view v1; |
drop table t1; |
Actual result:
explain select * from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3) |
and c1 = 2 |
and exists (select 'X' from v1 a where a.c1 = v1.c1); |
id select_type table type possible_keys key key_len ref rows Extra |
1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where |
1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) |
2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using where |
explain delete from v1 where v1.c2 in (select max(a.c2) from t1 a where a.c3 = v1.c3) |
and c1 = 2 |
and exists (select 'X' from v1 a where a.c1 = v1.c1); |
id select_type table type possible_keys key key_len ref rows Extra |
1 PRIMARY t1 ALL NULL NULL NULL NULL 32 Using where |
3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 32 Using where |
2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 32 Using wher |