GROUP BY behavior change in Django 2.0 with annotate/extra

29 views
Skip to first unread message

Michael Soderstrom

unread,
Mar 9, 2018, 5:39:43 PM3/9/18
to Django users
In a 1.11 branch I had a complex raw sql snippet added to a query set via annotate.  

When I updated Django to 2.0, the query set behavior changed to include the raw sql in the GROUP BY which destroyed the performance.

The same behavior occurred using annotate and extra.

I was able to hack around it by overwriting the get_group_by_cols on my RawSQL instance to return an empty list, but that seems wrong.

Is the new behavior a bug or a feature and is there a less hacky way of handling this?

Tim Graham

unread,
Mar 12, 2018, 1:05:36 PM3/12/18
to Django users
I'd use git bisect to find the commit where the behavior changed in Django. That will likely yield some insight.

https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#bisecting-a-regression
Reply all
Reply to author
Forward
0 new messages