Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.1(EOL)
-
None
Description
create table t1 (id int); |
insert t1 values (1),(2),(3); |
create table t2 (id int, acc_id int); |
insert t2 values (1,1),(2,2),(3,3); |
explain delete from t1 where id in (select id from t2 where acc_id = 9999); |
explain delete uc from t1 as uc where uc. id in (select p. id from t2 p where p.acc_id = 9999); |
Attachments
Issue Links
- relates to
-
MDEV-7487 Semi-join optimization for single-table update/delete statements
-
- Closed
-
Just an example a little closer to what I saw. Version 10.0.24..
CREATE TABLE t1 (id INT PRIMARY KEY);
INSERT t1 VALUES (1),(2),(3);
CREATE TABLE t2 (id INT PRIMARY KEY, acc_id INT, KEY(acc_id));
INSERT t2 VALUES (1,1),(2,2),(3,3);
EXPLAIN DELETE FROM t1 WHERE id IN (SELECT id FROM t2 WHERE acc_id = 9999); # Table scan first!
EXPLAIN DELETE uc FROM t1 AS uc WHERE uc.id IN (SELECT p.id FROM t2 p WHERE p.acc_id = 9999); # the plan we want
EXPLAIN DELETE FROM t1 WHERE t1.id IN (SELECT t2.id FROM t2 WHERE t2.acc_id = 9999) RETURNING t1.id; # Even aliasing like this produceds the poor plan