mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
messages: Stop joining through every table.
Calling `.select_related()` with no arguments joins through every
possible table, recursively. In this case, this currently produces a
query which joins through forty-three tables.
This is rather inefficient, particularly for what is a very common
call which should be very fast.
No callsite depends on having prefetched any joined table on the
object; drop all of the joins.
(cherry picked from commit 6ace34c374)
This commit is contained in:
committed by
Tim Abbott
parent
105e699ac6
commit
ad21451d01
@@ -621,9 +621,7 @@ def get_usermessage_by_message_id(
|
||||
user_profile: UserProfile, message_id: int
|
||||
) -> Optional[UserMessage]:
|
||||
try:
|
||||
return UserMessage.objects.select_related().get(
|
||||
user_profile=user_profile, message_id=message_id
|
||||
)
|
||||
return UserMessage.objects.get(user_profile=user_profile, message_id=message_id)
|
||||
except UserMessage.DoesNotExist:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user