On 14 Jul 2011 00:13, "bruno desthuilliers" <[email protected]>
wrote:
>
> On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]"
> <[email protected]> wrote:
>
> > _users = map(lambda x: x.get('memberid'),
Members.objects.filter(
> > username = self.username
> > ).values('memberid'))
>
> What's wrong with values_list ?
>
> member_ids = Members.objects.filter(
> username = self.username
> ).values_list('memberid', flat=True)
I didn't know about values_list(), thanks for this :)
>
>
> And FWIW, did you try the obvious:
>
> return Session.objects.filter(
> member__username=self.username,
> is_fake = 0
> ).order_by("-id")
If you look at the original query i pasted, you'll see that this
modification wouldn't have been any better (as they both would have
generated the same query). The problem is that mysql does strange ass things
when it comes to nested lookups or w/e its called. But tbh, ive come across
so many times when its faster to perform operations outside of mysql, than
it is inside.. the more i use mysql, the more i see how flawed it is :X
>
> (not that it might necessarily be faster - depending on your dataset,
> indexes, hardware and whatnot).
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
[email protected].
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.