Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-16 Thread Russell Keith-Magee
On Tue, Feb 16, 2010 at 4:43 AM, Greg Brown wrote: > Ok, here goes: > > First, some background - UserProfile is the > settings.AUTH_PROFILE_MODULE and the Application model has a > ForeignKey to User. There's ~90,000 users/userprofiles, ~110,000 > applications (most

Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-15 Thread Greg Brown
That's a good point, but then the ird_number field (on UserProfile) is inaccessible. I'd need to do something like User.objects.values('first_name', 'last_name', 'pk', 'userprofile__ird_number').annotate( Max('application__creation_date'),

Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-15 Thread Dj Gilcrease
On Mon, Feb 15, 2010 at 1:43 PM, Greg Brown wrote: > The queryset giving the problem is > > UserProfile.objects.values( >        'ird_number', 'user__first_name', 'user__last_name', 'user__pk', >    ).annotate( >        Max('user__application__creation_date'), >    

Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-15 Thread Greg Brown
Ok, here goes: First, some background - UserProfile is the settings.AUTH_PROFILE_MODULE and the Application model has a ForeignKey to User. There's ~90,000 users/userprofiles, ~110,000 applications (most have only one application, some have 2). The database is mysql. If that's not enough info,

Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-14 Thread Russell Keith-Magee
On Mon, Feb 15, 2010 at 6:30 AM, Greg wrote: > I have a large-ish query which is taking ~10 seconds to run, but I can > get it down to less than a second by changing the group by part of the > query from > >    GROUP BY `refunds_userprofile`.`ird_number` , >

Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-14 Thread Daniel Roseman
On Feb 14, 10:30 pm, Greg wrote: > I have a large-ish query which is taking ~10 seconds to run, but I can > get it down to less than a second by changing the group by part of the > query from > >     GROUP BY `refunds_userprofile`.`ird_number` , >

How do I manually set the "GROUP BY" for a django queryset?

2010-02-14 Thread Greg
I have a large-ish query which is taking ~10 seconds to run, but I can get it down to less than a second by changing the group by part of the query from GROUP BY `refunds_userprofile`.`ird_number` , `auth_user`.`first_name` , `auth_user`.`last_name` , `refunds_userprofile`.`user_id` ,