Modify ↓
Opened 12 years ago
Closed 12 years ago
#10795 closed defect (duplicate)
Trac fetches entire permissions table several times during request
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | project | Version: | 0.12.3 |
Severity: | normal | Keywords: | permission |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
We've found trac fetching the entire contents of the permission table one time for each user in the database on every request. This was slowing down our instance considerably.
Here is a patch fixing this issue:
Index: trac/perm.py =================================================================== --- trac/perm.py (revision 11167) +++ trac/perm.py (working copy) @@ -156,7 +156,7 @@ permissions and groups. """ implements(IPermissionStore) - + _user_perms = None group_providers = ExtensionPoint(IPermissionGroupProvider) def get_user_permissions(self, username): @@ -174,9 +174,11 @@ actions = set([]) db = self.env.get_db_cnx() - cursor = db.cursor() - cursor.execute("SELECT username,action FROM permission") - rows = cursor.fetchall() + if (self._user_perms == None): + cursor = db.cursor() + cursor.execute("SELECT username,action FROM permission") + self._user_perms = cursor.fetchall() + rows = self._user_perms while True: num_users = len(subjects) num_actions = len(actions)
Attachments (0)
Change History (1)
comment:1 by , 12 years ago
Milestone: | 0.12.4 |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This has been fixed in [11032], as part of #4245.