Bug #71171 | Optimizer executes inperformant subquery first | ||
---|---|---|---|
Submitted: | 18 Dec 2013 10:40 | Modified: | 4 Feb 2014 14:40 |
Reporter: | Martin Kirchner | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 5.6.14 | OS: | Linux (Debian 7.1) |
Assigned to: | CPU Architecture: | Any |
[18 Dec 2013 10:40]
Martin Kirchner
[18 Dec 2013 11:20]
MySQL Verification Team
Thank you for the bug report. Please provide the dump table file. Thanks in advance.
[18 Dec 2013 11:21]
Martin Kirchner
See FTP server
[18 Dec 2013 12:49]
Peter Laursen
Do the servers have same 'optimzer switch' setting (http://dev.mysql.com/doc/refman/5.6/en/switchable-optimizations.html) and are they exactly same versions (ie. both 5.6.14)? Peter (not a MySQL/Oracle person)
[18 Dec 2013 13:16]
Martin Kirchner
Versions are identical 5.6.14. Optimizer switches are identical: LIVE ==== kirchner@localhost [(none)]>SELECT @@optimizer_switch\G *************************** 1. row *************************** @@optimizer_switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,subquery_materialization_cost_based=on,use_index_extensions=on 1 row in set (0,00 sec) TEST ===kirchner@localhost [(none)]>SELECT @@optimizer_switch\G *************************** 1. row *************************** @@optimizer_switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,subquery_materialization_cost_based=on,use_index_extensions=on 1 row in set (0.00 sec)
[23 Dec 2013 15:16]
MySQL Verification Team
Hello Martin, Thank you for the bug report and test case. Verified as described. Thanks, Umesh
[3 Jan 2014 11:26]
Øystein Grøvlen
Optimizer trace for the given query is truncated. I have reported this issue as Bug#71273 (Optimizer trace error on range analysis of index on a binary column). I got around that issue by changing the server to not output the constants used for range scans in the trace. Then I got a valid optimizer trace, and I found the following in the trace when arriving at a prefix of the "good" plan: "pruned_by_eq_ref_heuristic": true Not yet sure exactly what happens here, but for some reason the good planned is pruned by the join optimizer. Fortunately, it is possible to turn off this pruning by setting a variable: set optimizer_prune_level = 0; Now I get the good plan.
[4 Feb 2014 14:40]
Martin Kirchner
Please also look at http://bugs.mysql.com/bug.php?id=71584. That is the same problem with a different query. Thanks.