mirror of https://github.com/zulip/zulip.git
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.
This commit is contained in:
parent
a5cf0ec526
commit
6ace34c374
|
@ -622,9 +622,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
|
||||
|
||||
|
|
Loading…
Reference in New Issue