Bug #52081 | Index hint/forcing for GROUP BY / ORDER BY is broken | ||
---|---|---|---|
Submitted: | 16 Mar 2010 8:38 | Modified: | 13 Aug 2010 2:47 |
Reporter: | Ole John Aske | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.1.41, 5.1.44, 5.6.99 | OS: | Any |
Assigned to: | Jørgen Løland | CPU Architecture: | Any |
[16 Mar 2010 8:38]
Ole John Aske
[16 Mar 2010 9:42]
Sveta Smirnova
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Because of this, we hope you add your comments to the original bug instead. Thank you for your interest in MySQL. Duplicate of bug #45373
[16 Mar 2010 10:07]
Ole John Aske
I do not agree that this is a duplicate of bug45373. - Bug#45373 basically covers that EXPLAIN *indicate* incorrect index usage. - This bug (#52081) shows by increased execution time that index hints do not work as expected (Sidenote: If I EXPLAIN my examples they actually claims that the correct index *is* used - Which they aren't) When JOIN:exec() is executed with the DESCRIBE option it actually recalculate its own index usage *outside* the normal execution path for execute. It may therefore end up explaining another index usage than actually *is* executed· As the code path is not the same for EXPLAIN & execute, I would also claim that these bugs are not a duplicate of each other. My proposed fix is also inside the codepath which is only taken by a full execute, and does not affect/fix the EXPLAINed output in bug#45373. Neither would a fix for the incorrect EXPLAIN in bug#45373 fix this bug - or the actual index usage. A much better design had of course been to always calculate index usage in a common place prior to both EXPLAIN and execute.... Setting status back to 'Open' for a new evaluation based in this comment.
[16 Mar 2010 10:35]
Sveta Smirnova
Thank you for the feedback. You are correct: explain shows same results for all queries. Setting to "Verified'.
[16 Mar 2010 11:42]
Jørgen Løland
This was fixed in 6.0 as part of BUG#49867, but not ported back since that bug was only repeatable i 6.0
[16 Mar 2010 11:46]
Ole John Aske
It should be simple to correct the TRUE / FALSE logic though in the 5.1 branch.
[17 Mar 2010 9:36]
Jørgen Løland
Ole John, yes this should be very easy to fix with minimal risk. Awaiting decision from triage.
[19 Mar 2010 13:43]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/103822 3412 Jorgen Loland 2010-03-19 Bug#52081: Index hint/forcing for GROUP BY / ORDER BY is broken Found during code inspection: There is a mixup between GROUP BY and ORDER BY in which indexes that should be considered/allowed during optimization of a query. The bug is a simple mixup of argument 'is_order_by' to create_sort_index() in JOIN::exec(). No test case committed as only problem is increased execution time due to wrong plan, and this does not show in EXPLAIN. @ sql/sql_select.cc Fixed mixup between GROUP BY/ORDER BY for JOIN::exec() call to create_sort_index().
[19 Mar 2010 14:31]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/103848 3131 Jorgen Loland 2010-03-19 Bug#52081: Index hint/forcing for GROUP BY / ORDER BY is broken Found during code inspection: There is a mixup between GROUP BY and ORDER BY in which indexes that should be considered/allowed during optimization of a query. The bug is a simple mixup of argument 'is_order_by' to create_sort_index() in JOIN::exec(). No test case included as only problem is increased execution time due to wrong plan, and this does not show in EXPLAIN. @ sql/sql_select.cc Fixed mixup between GROUP BY/ORDER BY for JOIN::exec() call to create_sort_index().
[19 Mar 2010 14:41]
Jørgen Løland
Pushed to next-mr-bugfixing.
[19 Mar 2010 14:50]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/103856 3984 Jorgen Loland 2010-03-19 [merge] Null-merge BUG#52081 from 5.1-bugteam to mysql-pe. Fix already present in 6.0 codebase.
[19 Mar 2010 14:51]
Jørgen Løland
Null-merged cs to 6.0
[24 Mar 2010 8:15]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100324081249-yfwol7qtcek6dh7w) (version source revid:alik@sun.com-20100324081113-kc7x1iytnplww91u) (merge vers: 6.0.14-alpha) (pib:16)
[24 Mar 2010 8:18]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100324081159-5b8juv8ldiqwce8v) (version source revid:alik@sun.com-20100324081105-y72rautcea375zxm) (pib:16)
[26 Mar 2010 8:31]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100326081944-qja07qklw1p2w7jb) (version source revid:alik@sun.com-20100325073410-4t4i9gu2u1pge7xb) (merge vers: 6.0.14-alpha) (pib:16)
[4 Aug 2010 8:06]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:alik@sun.com-20100324081105-y72rautcea375zxm) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 8:22]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:alik@sun.com-20100324081105-y72rautcea375zxm) (merge vers: 5.6.99-m4) (pib:18)
[13 Aug 2010 2:47]
Paul DuBois
Noted in 5.6.0, 6.0.14 changelogs. There was a mixup between GROUP BY and ORDER BY concerining which indexes should be considered or permitted during query optimization.