Django

Code

Ticket #2189 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] Auth runs unnecessary SQL to get permissions

Reported by: konrad@gwu.edu Assigned to: adrian
Milestone: Component: Contrib apps
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

optimize_auth.diff (0.6 kB) - added by konrad@gwu.edu on 06/18/06 11:12:34.
patch for trunk/django/contrib/auth/models.py

Change History

06/18/06 11:12:34 changed by konrad@gwu.edu

  • attachment optimize_auth.diff added.

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

06/18/06 11:12:53 changed by anonymous

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

06/18/06 11:35:25 changed by anonymous

  • summary changed from [patch] Admin runs unnecessary SQL to get permissions to [patch] Auth runs unnecessary SQL to get permissions.
  • component changed from Admin interface to Contrib apps.
  • version deleted.
  • milestone deleted.

06/27/06 20:17:58 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [3162].


Add/Change #2189 ([patch] Auth runs unnecessary SQL to get permissions)




Change Properties
Action