Bug #39786 | Explain doesn't show key with order by in derived table. | ||
---|---|---|---|
Submitted: | 1 Oct 2008 17:56 | Modified: | 12 Oct 2012 10:59 |
Reporter: | Shannon Wade | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.1.26 | OS: | Any |
Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
[1 Oct 2008 17:56]
Shannon Wade
[1 Oct 2008 18:07]
Sergey Petrunya
This is a known property. The observed effects are manifestations of the fact that at the moment FROM subqueries are resolved using this strategy: 1. Optimize and run the FROM subquery and capture the result into temp table. The temp table has no indexes, if the records in the temptable happen to be ordered, mysql won't use that fact. 2. Optimize and run the parent select. (see also http://s.petrunia.net/blog/?p=43, slide #3).
[1 Oct 2008 18:09]
Sergey Petrunya
Evgen Potemkin is working on FROM subqueries, see WL#3485. AFAIU the problem reported in this bug should go away when WL#3485 is implemented. At the moment the target version for WL#3485 is 6.1
[2 Oct 2008 15:38]
MySQL Verification Team
Hi sergey, Could you clarify this behavior for me, I'm not sure I understand why the key is only shown in certain circumstances along with the Handler_read_key behavior (in description) when they are not. If the temp table has no indexes why would key be shown sometimes and sometimes not? Also below with a sum & group by it shows the key and rows=2 with an order by inside. mysql> explain select * -> from ( -> select c2, c3, sum(c5) -> from t1 -> where c3 in ( 2,3 ) -> and c4=2 -> group by c2,c3 -> order by c5 -> ) x \G *************************** 1. row *************************** id: 1 select_type: PRIMARY table: <derived2> type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 2 Extra: *************************** 2. row *************************** id: 2 select_type: DERIVED table: t1 type: range possible_keys: test key: test key_len: 8 ref: NULL rows: 2 Extra: Using where; Using temporary; Using filesort 2 rows in set (0.00 sec)
[9 Oct 2008 16:58]
Sergey Petrunya
What was said above is all true however Shannon has drawn my attention that the posted EXPLAINs also indicate another problem. Investigating...
[12 Oct 2012 10:58]
Olav Sandstå
This bug has been fixed in MySQL 5.5.26.