#8408: Add a new meta option: don't do count(*) in admin -------------------------------+------------------------------------------- Reporter: LI Daobing | Owner: Thomas Chaumeny Type: New feature | Status: new Component: contrib.admin | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+------------------------------------------- Changes (by Matthew Betts):
* status: closed => new * resolution: fixed => Comment: As per Josh's comment a {{{count(*)}}} is still executed by the paginator when using the admin, even with {{{show_full_result_count=False}}}. This takes multiple seconds when querying tens of millions of rows. You can hack around the count(*) query by implementing a custom Paginator with either an [https://medium.com/squad-engineering/estimated-counts-for- faster-django-admin-change-list-963cbf43683e appromixiate] or a fixed count. {{{ from django.core.paginator import Paginator class FixedCountPaginator(Paginator): @property def count(self): return 1000 class MyModelAdmin(admin.ModelAdmin): show_full_result_count=False paginator = FixedCountPaginator }}} I'd like to fix this properly by either paginating without requesting the number of rows / pages or disabling pagination. {{{ class MyModelAdmin(admin.ModelAdmin): show_full_result_count=False no_count = False }}} I've put up a [https://github.com/django/django/pull/8858/files pull request] to demonstrate the changes required to achieve this. It changes the pagination widget in the admin to display [Prev, PAGE, Next]. Changing this to a `show_pagination` field that disables pagination would also solve the {{{count(*)}}} issue and may be more consistent / straight forward. {{{ class MyModelAdmin(admin.ModelAdmin): show_full_result_count=False show_pagination = True }}} -- Ticket URL: <https://code.djangoproject.com/ticket/8408#comment:46> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.fb3da72fc3afaadf6c26ed9adc4c4ed4%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.