django-qsstats icon indicating copy to clipboard operation
django-qsstats copied to clipboard

Do not evaluate the queryset just for a check!

Open davidbgk opened this issue 15 years ago • 2 comments

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 :)

davidbgk avatar Oct 29 '10 22:10 davidbgk

Hi David, this issue is resolved in my fork: http://bitbucket.org/kmike/django-qsstats-magic/src

kmike avatar Oct 29 '10 23:10 kmike

Thanks Mikhail, I didn't noticed your fork was on Bitbucket too. I'll be able to report issues with your fork directly there.

davidbgk avatar Oct 30 '10 00:10 davidbgk