mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
Optimize get_occupied_streams
In a test run with a hand-constructed query, this sped up the query time from 280ms to 50ms. (imported from commit 8cbe199ca50a487491d13d6d6ef940ea668c1038)
This commit is contained in:
committed by
Steve Howell
parent
2090d6ee27
commit
eda05d23bf
@@ -2732,7 +2732,8 @@ def realm_aliases(realm):
|
||||
|
||||
def get_occupied_streams(realm):
|
||||
""" Get streams with subscribers """
|
||||
subs_filter = Subscription.objects.filter(active=True).values('recipient_id')
|
||||
subs_filter = Subscription.objects.filter(active=True, user_profile__realm=realm,
|
||||
user_profile__is_active=True).values('recipient_id')
|
||||
stream_ids = Recipient.objects.filter(
|
||||
type=Recipient.STREAM, id__in=subs_filter).values('type_id')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user