Re: Optimizing Django ORM SQL queries when in a loop

2008-08-28 Thread [EMAIL PROTECTED]
I'm going to give this a try. I'll let you know how I get on! Thanks guys! Mike. On Aug 27, 6:18 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > user_id_list=User.objects.filter(whatever).values_list('id', > flat=True) > posts=Post.objects.filter(user__id__in=user_id_list) > > Would that

Re: Optimizing Django ORM SQL queries when in a loop

2008-08-27 Thread [EMAIL PROTECTED]
user_id_list=User.objects.filter(whatever).values_list('id', flat=True) posts=Post.objects.filter(user__id__in=user_id_list) Would that work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Optimizing Django ORM SQL queries when in a loop

2008-08-27 Thread [EMAIL PROTECTED]
Hi Malcolm, Thanks very much for your help! I was (up until a few weeks ago) running off of the trunk, but I've stopped at an earlier revision (7922, I think). I kept updating but things kept breaking so I thought I'd just finalise the revision. I did actually give it a go using Q objects

Re: Optimizing Django ORM SQL queries when in a loop

2008-08-26 Thread Malcolm Tredinnick
On Tue, 2008-08-26 at 08:05 -0700, [EMAIL PROTECTED] wrote: > Hi guys, > > I'm trying to optimize one of my views that is doing a rather (naive?) > query like this: > > ... > post_stream = Post.objects.filter(poster=some_user) > for other_user in other_user_queryset: > post_stream =