activity: Use select_related when querying UserActivity records

On my dev machine this cuts /activity load time with lots of users by more than
2/3.  I expect the gains will be even greater in production due to the greater
relative cost of database queries.

(imported from commit 0391cb29f66b618b4b99902d9fb9ab0a6cff0cb3)
This commit is contained in:
Keegan McAllister 2013-02-11 16:10:00 -05:00
parent 78398fab95
commit 6fba03a0a4
1 changed files with 1 additions and 1 deletions

View File

@ -1213,7 +1213,7 @@ class ActivityTable(object):
self.has_pointer = True
for record in UserActivity.objects.filter(
query=url,
client__name=client_name):
client__name=client_name).select_related():
row = self.rows.setdefault(record.user_profile.user.email, {})
row['realm'] = record.user_profile.realm.domain
row['full_name'] = record.user_profile.full_name