Opened 19 years ago

Closed 18 years ago

Last modified 18 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: no UI/UX: no

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@… 19 years ago.
patch for trunk/django/contrib/auth/models.py

Download all attachments as: .zip

Change History (4)

by konrad@…, 19 years ago

Attachment: optimize_auth.diff added

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

comment:1 by anonymous, 19 years ago

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

comment:2 by anonymous, 19 years ago

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 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

Fixed in [3162].

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