Bug #39756 | EXPLAIN for uncorrelated NOT EXISTS query is slow | ||
---|---|---|---|
Submitted: | 30 Sep 2008 12:59 | Modified: | 5 May 2014 5:54 |
Reporter: | Roy Lyseng | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S5 (Performance) |
Version: | 6.0,5.4, 5.1 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[30 Sep 2008 12:59]
Roy Lyseng
[30 Sep 2008 13:41]
Valeriy Kravchuk
Verified just as described: C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot -P3311 test Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 6.0.6-alpha-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create table t1( -> id integer primary key, -> u integer not null unique, -> v integer not null, -> vi integer not null, index(vi), -> s char(1)); Query OK, 0 rows affected (0.08 sec) mysql> create table t2( -> id integer primary key, -> u integer not null unique, -> v integer not null, -> vi integer not null, index(vi), -> s char(1)); Query OK, 0 rows affected (0.09 sec) mysql> insert into t1 values(10, 10, 10, 10, 'l'); Query OK, 1 row affected (0.05 sec) mysql> insert into t2 values(10, 10, 10, 10, 'r'); Query OK, 1 row affected (0.06 sec) mysql> insert into t1 values(20, 20, 20, 20, 'l'); Query OK, 1 row affected (0.05 sec) mysql> insert into t2 values(30, 30, 30, 30, 'r'); Query OK, 1 row affected (0.06 sec) mysql> insert into t1 values(40, 40, 40, 40, 'l'); Query OK, 1 row affected (0.05 sec) mysql> insert into t1 values(41, 41, 40, 40, 'l'); Query OK, 1 row affected (0.05 sec) mysql> insert into t1 values(50, 50, 50, 50, 'l'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values(51, 51, 50, 50, 'l'); Query OK, 1 row affected (0.05 sec) mysql> insert into t2 values(50, 50, 50, 50, 'r'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values(60, 60, 60, 60, 'l'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values(61, 61, 60, 60, 'l'); Query OK, 1 row affected (0.06 sec) mysql> insert into t2 values(60, 60, 60, 60, 'r'); Query OK, 1 row affected (0.11 sec) mysql> insert into t2 values(61, 61, 60, 60, 'r'); Query OK, 1 row affected (0.08 sec) mysql> insert into t1 values(70, 70, 70, 70, 'l'); Query OK, 1 row affected (0.11 sec) mysql> insert into t2 values(70, 70, 70, 70, 'r'); Query OK, 1 row affected (0.05 sec) mysql> insert into t2 values(71, 71, 70, 70, 'r'); Query OK, 1 row affected (0.05 sec) mysql> insert into t2 values(80, 80, 80, 80, 'r'); Query OK, 1 row affected (0.05 sec) mysql> insert into t2 values(81, 81, 80, 80, 'r'); Query OK, 1 row affected (0.05 sec) mysql> explain select * from t1 where not exists(select * from t2)\G *************************** 1. row *************************** id: 1 select_type: PRIMARY table: NULL type: NULL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: NULL Extra: Impossible WHERE *************************** 2. row *************************** id: 2 select_type: SUBQUERY table: t2 type: index possible_keys: NULL key: PRIMARY key_len: 4 ref: NULL rows: 9 Extra: Using index 2 rows in set (0.00 sec)
[14 Jul 2009 22:28]
Patrick Crews
The explain query is the same in 5.1
[14 Sep 2010 11:44]
Tor Didriksen
Maybe the solution is as simple as this. It breaks a handful of 'explain' results in the test suite, nothing else that I can see. // Item_exists_subselect virtual bool is_expensive_processor(uchar *arg) { return !is_correlated; }