From a1cbeb9afbbf0f16e1ffa1891575fbc2c3edae74 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Wed, 10 Dec 2008 05:19:27 +0000 Subject: If an SQL query doesn't specify any ordering, avoid the implicit sort that happens with MySQL when a "GROUP BY" clause is included. This is a backend-specific operation, so any other databases requiring similar encouragement can have a function added to their own backend code. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9637 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/query.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index e30deee29b..8c5ef3355e 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -288,6 +288,8 @@ class BaseQuery(object): if self.group_by: grouping = self.get_grouping() result.append('GROUP BY %s' % ', '.join(grouping)) + if not ordering: + ordering = self.connection.ops.force_no_ordering() if self.having: having, h_params = self.get_having() -- cgit v1.3