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

approx_count can go further

Open adamchainz opened this issue 10 years ago • 2 comments
trafficstars

The approx_count function can be used to count QuerySets other than the basic full-table ones it accepts at current. For example, you can get a reliable(-ish) approximate count on an index range, such as id BETWEEN 1 AND 500 (with id = primary key). This would make it much more useful too.

adamchainz avatar Mar 21 '15 18:03 adamchainz

What might be involved with implementing this?

We use approx count in some places in django admin so any improvements/extensions would be great to have.

jheld avatar Apr 25 '20 01:04 jheld

The idea is to expand can_approx_count to cover other situations, without hitting false positives.

Looking again at it, I'm not sure how feasible it is, given the information we have in Django about the database layout and the complexity of introspecting every possible modification to a QuerySet.

adamchainz avatar Apr 25 '20 09:04 adamchainz

I think this is probably too hard.

adamchainz avatar Aug 08 '23 05:08 adamchainz