#34593: Django admin list does same Count query twice when there are no filters
------------------------------------------------+--------------------------
               Reporter:  Alex                  |          Owner:  Alex
                   Type:  Cleanup/optimization  |         Status:  assigned
              Component:  contrib.admin         |        Version:  4.2
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  1
                  UI/UX:  0                     |
------------------------------------------------+--------------------------
 The issue is due to this code:


 {{{
         # Get the number of objects, with admin filters applied.
         result_count = paginator.count  # First count() query

         # Get the total number of objects, with no admin filters applied.
         if self.model_admin.show_full_result_count:
             full_result_count = self.root_queryset.count()  # Second
 count() query
         else:
             full_result_count = None
 }}}

 When the there are no filters, the same query is done for {{{ result_count
 }}} and {{{ full_result_count }}} and the value will always be the same.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34593>
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/0107018849574644-514c30af-339f-45de-97e2-2401718e778a-000000%40eu-central-1.amazonses.com.

Reply via email to