#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 =>


 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

 from django.core.paginator import Paginator
 class FixedCountPaginator(Paginator):

     def count(self):
         return 1000

 class MyModelAdmin(admin.ModelAdmin):
     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):
     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

 class MyModelAdmin(admin.ModelAdmin):
     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 
For more options, visit https://groups.google.com/d/optout.

Reply via email to