#31204: Paginator with count = 0 always produce non-limited QuerySet
----------------------------------------------+------------------------
Reporter: Alexander Pervakov | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------------+------------------------
Problem:
Custom paginator, i.e. approximate PostgreSQL paginator based on
pg_class.reltuples, could return count = 0 when vacuum haven't run yet.
QuerySet doesn't set limit on following select query, and in my case I've
got max memory exceeded error because Django Admin have tried to visualise
all 3M rows from my DB.
Solution:
As a workaround for that case one should always use limit for one's custom
``count``, a good candidate for this is a Paginator.per_page attribute.
Django itself could limits count as well, but when I've tried to implement
it myself a 3 tests was failed (because in these tests Django Admin trust
to ChangeList.result_count), and I've no time for deeper investigation.
So my github PR isn't going beyond and only point to this case in a docs
and in a count method comment to help curious ones in their custom
Paginator implementation.
--
Ticket URL: <https://code.djangoproject.com/ticket/31204>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.d5fe23c9fe6b14d1ba3cfccb5ce6e58b%40djangoproject.com.