mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +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
@@ -845,7 +845,7 @@ def get_occupied_streams(realm: Realm) -> QuerySet[Stream]:
|
||||
)
|
||||
occupied_streams = (
|
||||
Stream.objects.filter(realm=realm, deactivated=False)
|
||||
.annotate(occupied=exists_expression)
|
||||
.alias(occupied=exists_expression)
|
||||
.filter(occupied=True)
|
||||
)
|
||||
return occupied_streams
|
||||
@@ -1002,7 +1002,7 @@ def get_subscribed_private_streams_for_user(user_profile: UserProfile) -> QueryS
|
||||
)
|
||||
subscribed_private_streams = (
|
||||
Stream.objects.filter(realm=user_profile.realm, invite_only=True, deactivated=False)
|
||||
.annotate(subscribed=exists_expression)
|
||||
.alias(subscribed=exists_expression)
|
||||
.filter(subscribed=True)
|
||||
)
|
||||
return subscribed_private_streams
|
||||
|
||||
Reference in New Issue
Block a user