mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
performance: Add get_subscriptions_for_send_message.
This new function optimizes how we fetch subscriptions for streams. Basically, it excludes most long-term-idle users from the query. With 8k users, of which all but 400 are long term idle, this speeds up get_recipient_info from about 150ms to 50ms. Overall this change appears to save a factor of 2-3 in the backend processing time for sending or editing a message in large, public streams in chat.zulip.org (at 18K users today).
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
from typing import Set
|
||||
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from zerver.lib.stream_subscription import get_active_subscriptions_for_stream_id
|
||||
from zerver.models import MutedTopic
|
||||
|
||||
|
||||
@@ -26,8 +23,3 @@ class StreamTopicTarget:
|
||||
"user_profile_id",
|
||||
)
|
||||
return {row["user_profile_id"] for row in query}
|
||||
|
||||
def get_active_subscriptions(self) -> QuerySet:
|
||||
return get_active_subscriptions_for_stream_id(
|
||||
self.stream_id, include_deactivated_users=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user