ops, a small correction. i meant: User.objects.filter(id__in=[q.user.id for q in Quiz.objects.filter(score__gt=90)])
-- oMat On May 24, 3:12 pm, omat <o...@gezgin.com> wrote: > Hi All, > > I have a Quiz model, which is related to the User model by a > ForeignKey. I want to get a queryset of users that have a certain > score. > > I want to avoid: > > User.objects.filter(id__in=[u.id for u in > Quiz.objects.filter(score__gt=90)]) > > As there are about 1 million users, this is deadly slow. > > What is the optimal way of doing this? > > Thanks, > oMat > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://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 django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.