django-polymorphic
django-polymorphic copied to clipboard
A query for each 100 results returned from PolymorphicModel
I've found that queries done with the PolymorphicModel, cause a query to the database for every 100 objects in the queryset.
The following code block shows the steps I used to check the query count.
(looking at the queries executed, I've noticed most of the queries are the same, with different parameters (object id's)).
from django.db import connection
qs = PolymorphicModelA.objects.all()
print(len(connection.queries))
list(qs) # Evaluating the queryset
print(len(connection.queries))
After looking into it a little more, the 100 object chunk derives from Polymorphic_QuerySet_objects_per_request in the query.py file (used by the PolymorphicModelIterable).
Simply removing the PolymorphicModel from the base model (models.Model instead) brings the query count back to normal.
Is this intended? If so, it sounds weird, considering part of the reason to use django-polymorphic in the first place is to avoid excessive database calls.
Thanks.