Is there any way to remove select related from queryset?
I found, that django add JOIN on count() operation to sql query.
So, if we have code like this:
entities = Entities.objects.select_related('subentity').all()
#We will have INNER JOIN here..
entities.count()
I’m looking for a way to remove join.
One important detail – I got this queryset into django paginator, so I can’t simply write
Entities.objects.all().count()
Can you show the code where you need this, I think refactoring is the best answer here.
If you want quick answer,
entities.query.select_related = False, but it’s rather hacky (and don’t forget to restore the value if you will needselect_relatedlater).