mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
django: Switch to .alias() instead .annotate() where possible.
When using the sub-expression purely for filtering, and not for accessing the value in the resultset, .alias() is potentially faster since it does not pull the value in as well.
This commit is contained in:
committed by
Tim Abbott
parent
e1a9473bd6
commit
d5a4941691
@@ -203,7 +203,7 @@ def add_missing_messages(user_profile: UserProfile) -> None:
|
||||
recipient_ids.append(sub["recipient_id"])
|
||||
|
||||
new_stream_msgs = (
|
||||
Message.objects.annotate(
|
||||
Message.objects.alias(
|
||||
has_user_message=Exists(
|
||||
UserMessage.objects.filter(
|
||||
user_profile_id=user_profile,
|
||||
@@ -213,7 +213,7 @@ def add_missing_messages(user_profile: UserProfile) -> None:
|
||||
)
|
||||
.filter(
|
||||
# Uses index: zerver_message_realm_recipient_id
|
||||
has_user_message=0,
|
||||
has_user_message=False,
|
||||
realm_id=user_profile.realm_id,
|
||||
recipient_id__in=recipient_ids,
|
||||
id__gt=user_profile.last_active_message_id,
|
||||
|
||||
Reference in New Issue
Block a user