django-qsstats
django-qsstats copied to clipboard
Do not evaluate the queryset just for a check!
I was surprised that I didn't get a boost in performances from a naive implementation to your one which includes aggregation. I eventually found the issue while investing with the django debug toolbar.
In QuerySetStats.check_qs(), you evaluate the whole queryset in the test:
if not self.qs:
It's an unnecessary performances killer, I propose:
if not hasattr(self.qs, 'select_related'): # quack like a qs
or whatever relevant attribute you want :)
Hi David, this issue is resolved in my fork: http://bitbucket.org/kmike/django-qsstats-magic/src
Thanks Mikhail, I didn't noticed your fork was on Bitbucket too. I'll be able to report issues with your fork directly there.