#11881: ORDER BY in aggregate subqueries is not necessary and might causes on
some
SQL servers
----------------------------------------------------------------------+-----
Reporter: egenix_viktor |
Owner: nobody
Status: new |
Milestone:
Component: Database layer (models, ORM) |
Version: 1.1
Keywords: aggregate subquery order_by optimization incompatibility |
Stage: Unreviewed
Has_patch: 1 |
----------------------------------------------------------------------+-----
Some SQL servers, like `MS SQL 2005` does not allow `ORDER BY` in
subqueries without a `TOP` modifier. (It might apply to other database
servers as well.) It is also suboptimal to use `ORDER BY` in the subquery
of an aggregate `SELECT`, since it does not affect the result.
It might be better to just clear ordering in the subquery in this case. I
suggest adding the following line in the `BaseQuery.get_aggregation`
method before the `query.add_subquery(obj)` call:
{{{
obj.clear_ordering(True)
}}}
Patch against the `db\models\sql\query.py` file of the 1.1 release version
has been attached.
--
Ticket URL: <http://code.djangoproject.com/ticket/11881>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---