Opened 9 years ago

Last modified 21 months ago

#25230 assigned Cleanup/optimization

Change to Query.get_count() causes big performance hit — at Version 1

Reported by: dexity Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by dexity)

Recent pull merge https://github.com/django/django/commit/c7fd9b242d2d63406f1de6cc3204e35aaa025233?diff=unified generates SQL which causes severe performance hit when using distinct parameter.
Instead of getting something like:
SELECT DISTINCT COUNT('*') FROM some_model;

it generates SQL query which looks:
SELECT COUNT('*') FROM (SELECT DISTINCT * FROM some_model) subquery;

Related ticket: https://code.djangoproject.com/ticket/23875

Change History (1)

comment:1 by dexity, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top