GROUP BY behavior change in Django 2.0 with annotate/extra

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GROUP BY behavior change in Django 2.0 with annotate/extra

Michael Soderstrom
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?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/61299273-2bc4-41f1-8338-fd7aefb2d765%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: GROUP BY behavior change in Django 2.0 with annotate/extra

Tim Graham-2
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

On Friday, March 9, 2018 at 5:39:43 PM UTC-5, Michael Soderstrom wrote:
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?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/16fc7b70-ba9f-4761-b73c-7499a9b7a373%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.