#34158: Optimise count() for querysets that contain field lookups
-------------------------------------+-------------------------------------
     Reporter:  Irfan                |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 > Is there a way Django's {{{count()}}} can be optimised for such
 querysets?

 Not really. Moreover, this is a support question and Trac is not a support
 channel. Closing per TicketClosingReasons/UseSupportChannels.

 > This becomes especially useful for
 [https://docs.djangoproject.com/en/4.1/ref/paginator/ Paginators] where
 {{{count()}}} is used
 [https://github.com/django/django/blob/4.1.3/django/core/paginator.py#L78
 internally], and such querysets with large number of rows containing
 foreign key field lookups won't slowdown pagination due to the unnecessary
 joins.

 See #23771 for some ideas on how to optimize the `Paginator` case.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34158#comment:1>
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/010701847a3ef40e-a52a516b-c456-4c05-8ae0-7802ea811938-000000%40eu-central-1.amazonses.com.

Reply via email to