Opened 6 months ago

Closed 6 months ago

#35300 closed New feature (invalid)

Simple COUNT without OUTER JOIN

Reported by: Chrea Chanchhunneng Owned by: nobody
Component: Uncategorized Version: 4.2
Severity: Normal Keywords: reduce counting time,
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

as in django query, we support Count() in db.model and queryset.count(). But the problem are Count() creates the LEFT OUTER JOIN and queryset.count() does not support OuterRef("pk").

I hope there is a way to just simply count without LEFT OUTER JOIN to reduce the query time.

Change History (1)

comment:1 by Mariusz Felisiak, 6 months ago

Resolution: invalid
Status: newclosed

Thanks for the ticket, however I'm not sure what do you want to "count" and how do you expect to count related objects without JOINs. You could probably use .aggregate(Count(..)) in a subquery but it's hard to tell without a concrete example. Please first ask on the [https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels support channels (Trac is not one of them) where folks will be eager to help.

Note: See TracTickets for help on using tickets.
Back to Top