From e9ee05b2b26638a92603fa9b4e867d61a1f6cc43 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 30 Sep 2013 16:10:44 -0400 Subject: [PATCH] gather_subscriptions: Avoid extra queries fetching realm objects. (imported from commit 591083cfaff454b8ce48aacb5da7913b8fe0a38f) --- zerver/lib/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index f17e4cb087..a5dcb1e8bd 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1452,7 +1452,7 @@ def gather_subscriptions(user_profile): stream_ids = [sub.recipient.type_id for sub in subs] stream_hash = {} - for stream in Stream.objects.filter(id__in=stream_ids): + for stream in Stream.objects.select_related("realm").filter(id__in=stream_ids): stream_hash[stream.id] = stream subscribed = []