#34158: Optimise count() for querysets that contain field lookups
-------------------------------------+-------------------------------------
Reporter: Irfan | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
[https://github.com/mo3rfan/django-qs-
count/blob/main/test_orm/testapp/tests.py#L31-L32 These two lines are
equivalent in terms of the count], yet [https://github.com/mo3rfan/django-
qs-count/actions/runs/3467684164/jobs/5792783131#step:3:351 one is much
slower than the other].
Is there a way Django's {{{count()}}} can be optimised for such querysets?
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/34158>
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/010701847a2dae46-a18fa60c-9212-4f1b-85db-dfe3e0f1c177-000000%40eu-central-1.amazonses.com.