[MDEV-2424] LP:1000649 - EXPLAIN shows incorrectly a non-correlated constant IN subquery is correlated. Created: 2012-05-17  Updated: 2015-02-02  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Timour Katchaounov (Inactive) Assignee: Timour Katchaounov (Inactive)
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug1000649.xml    

 Description   

create table ten (a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int, b int, c int);
insert into t1 select a,a,a from ten;
create table five (a int, b int, c int);
insert into five select a,a,a from ten limit 5;

In MariaDB 5.5 the query transformed by IN-EXISTS is shown as a correlated, despite the fact it is all constant:

MariaDB [test]> explain extended select * from t1 where 33 in (select b from five) or c > 11;
------------------------------------------------------------------------------------

id select_type table type possible_keys key key_len ref rows filtered Extra

------------------------------------------------------------------------------------

1 PRIMARY t1 ALL NULL NULL NULL NULL 10 100.00 Using where
2 DEPENDENT SUBQUERY five ALL NULL NULL NULL NULL 5 100.00 Using where

------------------------------------------------------------------------------------

MariaDB [test]> show warnings;
----------------------------------------------------------------------------------------------------------------------

Level Code Message

----------------------------------------------------------------------------------------------------------------------

Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` > 11)

----------------------------------------------------------------------------------------------------------------------

In MariaDB 5.2 the query is correctly not shown as correlated:

MariaDB [test]> explain extended select * from t1 where 33 in (select b from five) or c > 11;
---------------------------------------------------------------------------

id select_type table type possible_keys key key_len ref rows filtered Extra

---------------------------------------------------------------------------

1 PRIMARY t1 ALL NULL NULL NULL NULL 10 100.00 Using where
2 SUBQUERY five ALL NULL NULL NULL NULL 5 100.00 Using where

---------------------------------------------------------------------------
2 rows in set, 1 warning (0.00 sec)

MariaDB [test]> show warnings;
------------------------------------------------------------------------------------------------------------------------------------

Level Code Message

------------------------------------------------------------------------------------------------------------------------------------

Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` > 11)

------------------------------------------------------------------------------------------------------------------------------------



 Comments   
Comment by Rasmus Johansson (Inactive) [ 2012-06-05 ]

Launchpad bug id: 1000649

Generated at Thu Feb 08 06:41:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.