Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#2189 closed enhancement (fixed)

[patch] Auth runs unnecessary SQL to get permissions

Reported by: konrad@… Owned by: Adrian Holovaty
Component: Contrib apps Version:
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

On each request, when the permissions are requested for a user this SQL gets executed a bunch of times, for each permission the user has:

SELECT `django_content_type`.`id`, `django_content_type`.`name`, `django_content_type`.`app_label`, `django_content_type`.`model` 
FROM `django_content_type` WHERE (`django_content_type`.`id` = %s)

Could all this be done in one statement using selected_related() instead of all()? Might be worth optimizing since it's per-request.

Attachments (1)

optimize_auth.diff (644 bytes) - added by konrad@… 10 years ago.
patch for trunk/django/contrib/auth/models.py

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by konrad@…

Attachment: optimize_auth.diff added

patch for trunk/django/contrib/auth/models.py

comment:1 Changed 10 years ago by anonymous

Summary: Admin runs unnecessary SQL to get permissions[patch] Admin runs unnecessary SQL to get permissions

comment:2 Changed 10 years ago by anonymous

Component: Admin interfaceContrib apps
milestone: Version 1.0
Summary: [patch] Admin runs unnecessary SQL to get permissions[patch] Auth runs unnecessary SQL to get permissions
Version: SVN

comment:3 Changed 10 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

Fixed in [3162].

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