mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
MWL#17: Table elimination
- Correctly handle the case where we have multi-table DELETE and a table that we're deleting from looks like it could be eliminated.
This commit is contained in:
parent
f3d0b1c04e
commit
21d2573908
3 changed files with 61 additions and 2 deletions
|
|
@ -278,3 +278,32 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 index NULL PRIMARY 10 NULL 2 Using index
|
||||
1 SIMPLE t2 ref a a 3 test.t1.a 2
|
||||
drop table t1, t2;
|
||||
#
|
||||
# check UPDATE/DELETE that look like they could be eliminated
|
||||
#
|
||||
create table t1 (a int primary key, b int);
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
update t1 left join t2 using (a) set t2.a=t2.a+100;
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
select * from t2;
|
||||
a b
|
||||
101 1
|
||||
102 2
|
||||
103 3
|
||||
delete from t2;
|
||||
insert into t2 select * from t1;
|
||||
delete t2 from t1 left join t2 using (a);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
select * from t2;
|
||||
a b
|
||||
drop table t1, t2;
|
||||
|
|
|
|||
|
|
@ -229,3 +229,23 @@ explain select t1.* from t1 left join t2 on t2.a=t1.a;
|
|||
|
||||
drop table t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # check UPDATE/DELETE that look like they could be eliminated
|
||||
--echo #
|
||||
create table t1 (a int primary key, b int);
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
update t1 left join t2 using (a) set t2.a=t2.a+100;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
delete from t2;
|
||||
insert into t2 select * from t1;
|
||||
|
||||
delete t2 from t1 left join t2 using (a);
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
drop table t1, t2;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue