Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2189 closed enhancement (fixed)

[patch] Auth runs unnecessary SQL to get permissions

Reported by: konrad@… Owned by: adrian
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@… 9 years ago.
patch for trunk/django/contrib/auth/models.py

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by konrad@…

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

comment:1 Changed 9 years ago by anonymous

  • Summary changed from Admin runs unnecessary SQL to get permissions to [patch] Admin runs unnecessary SQL to get permissions

comment:2 Changed 9 years ago by anonymous

  • Component changed from Admin interface to Contrib apps
  • milestone Version 1.0 deleted
  • Summary changed from [patch] Admin runs unnecessary SQL to get permissions to [patch] Auth runs unnecessary SQL to get permissions
  • Version SVN deleted

comment:3 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [3162].

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