﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34158	Optimise count() for querysets that contain field lookups	Irfan	nobody	"[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."	Cleanup/optimization	closed	Database layer (models, ORM)	4.1	Normal	invalid			Unreviewed	0	0	0	0	0	0
