I took this sample code here : Django ORM: Selecting related set
polls = Poll.objects.filter(category='foo')
choices = Choice.objects.filter(poll__in=polls)
My question is very simple : do you hit twice the database when you finally use the queryset choices ?
It will be one query, but containing an inner
SELECT; if you want to do some debugging on that, you could either use the marvellous django-debug-toolbar, or do something likeprint str(choices.query)which will output the raw sql of your query!