[MDEV-428] Select type DEPENDENT SUBQUERY in SHOW EXPLAIN vs SUBQUERY in EXPLAIN Created: 2012-08-02 Updated: 2012-08-02 Resolved: 2012-08-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 10.0.0 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
bzr version-info
Default optimizer_switch:
Test case:
|
| Comments |
| Comment by Sergei Petrunia [ 2012-08-02 ] |
|
Repetable only when the tables have type=MyISAM. Look at the query: SELECT * FROM t1 the subquery is t1 has column a, t3 has column c. `b` is only in table t2, which means the subquery IS correlated. |
| Comment by Sergei Petrunia [ 2012-08-02 ] |
|
I tried the testcase on MariaDB 5.2 (explicitly specified type=MYISAM for the tables to be certain). I've got: +id select_type table type possible_keys key key_len ref rows Extra |
| Comment by Sergei Petrunia [ 2012-08-02 ] |
|
I've debugged both EXPLAIN and SELECT. Both conclude that the subquery can only produce zero rows, however they arrive at the conclusion through different routes. EXPLAIN hits these lines in JOIN::optimize: if (conds && const_table_map != found_const_table_map && Note that the WHERE clause is replaced with Item_int(1) here. This is how correlated subquery becomes un-correlated. SELECT hits these lines in JOIN::optimize: if (const_table_map != found_const_table_map && The subquery is declared as "no matching row in const table", but its WHERE clause is not removed. |
| Comment by Sergei Petrunia [ 2012-08-02 ] |
|
Elena, please add a suppression, so that RQG doesn't consider a difference type=SUBQUERY Extra='Impossible WHERE noticed after reading const tables' meaningful. |
| Comment by Sergei Petrunia [ 2012-08-02 ] |
|
Won't fix; natural property of the code. |