Bug #47853 | Implicitly grouped queries do not need to use temporary tables | ||
---|---|---|---|
Submitted: | 6 Oct 2009 9:05 | Modified: | 24 Jan 2011 15:16 |
Reporter: | Jørgen Løland | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 5.1, 6.0 | OS: | Any |
Assigned to: | Jørgen Løland | CPU Architecture: | Any |
[6 Oct 2009 9:05]
Jørgen Løland
[17 Jan 2011 12:20]
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/128947 3520 Jorgen Loland 2011-01-17 BUG#47853: Implicitly grouped queries do not need to use temporary tables A query is implicitly grouped if it contains an aggregate function but no GROUP BY clause. Implicitly grouped queries return zero or one row, so ordering does not make sense. This patch removes the order by clause during the prepare() stage of the optimizer when implicitly ordered queries are detected. @ mysql-test/r/func_group.result Updated result file @ mysql-test/r/limit.result Updated result file @ mysql-test/r/subquery_nomat_nosj.result Updated result file @ mysql-test/r/subquery_none.result Updated result file @ sql/sql_select.cc Remove order by clause during prepare() if the query is implicitly grouped.
[24 Jan 2011 9:02]
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/129407 3544 Jorgen Loland 2011-01-24 BUG#47853: Implicitly grouped queries do not need to use temporary tables A query is implicitly grouped if it contains an aggregate function but no GROUP BY clause. Implicitly grouped queries return zero or one row, so ordering does not make sense. This patch removes the order by clause during the prepare() stage of the optimizer when implicitly ordered queries are detected. @ mysql-test/r/func_group.result Updated result file @ mysql-test/r/limit.result Updated result file @ mysql-test/r/subquery_nomat_nosj.result Updated result file @ mysql-test/r/subquery_none.result Updated result file @ sql/sql_select.cc Remove order by clause during prepare() if the query is implicitly grouped.
[24 Jan 2011 9:02]
Bugs System
Pushed into mysql-trunk 5.6.2 (revid:jorgen.loland@oracle.com-20110124090203-1grig6b522tmw4cf) (version source revid:jorgen.loland@oracle.com-20110124090203-1grig6b522tmw4cf) (merge vers: 5.6.2) (pib:24)
[24 Jan 2011 15:16]
Paul DuBois
Noted in 5.6.2 changelog. A query that contained an aggregate function but no GROUP BY clause was implicitly grouped. But implicitly grouped queries return zero or one row, so ordering does not make sense.
[4 Mar 2016 16:41]
Paul DuBois
Revised changelog entry: A query that contains an aggregate function but no GROUP BY clause is implicitly grouped. If such a query also contained an ORDER BY clause, the optimizer could choose to use a temporary table to perform the ordering. This is unnecessary because implicitly grouped queries return at most one row and need no ordering.