mirror of https://github.com/zulip/zulip.git
topic: Pass args to select_related call for Message objects.
This commit adds code to pass all the required arguments to select_related call for Message objects such that only the required related fields are fetched from the database. Previously, we did not pass any arguments to select_related, so all the directly and indirectly related fields were fetched when many of them were actually not being used and made the query unnecessarily complex.
This commit is contained in:
parent
36f8aba7db
commit
7ff5423e21
|
@ -160,7 +160,9 @@ def update_messages_for_topic_edit(
|
||||||
if propagate_mode == "change_later":
|
if propagate_mode == "change_later":
|
||||||
propagate_query = propagate_query & Q(id__gt=edited_message.id)
|
propagate_query = propagate_query & Q(id__gt=edited_message.id)
|
||||||
|
|
||||||
messages = Message.objects.filter(propagate_query).select_related()
|
messages = Message.objects.filter(propagate_query).select_related(
|
||||||
|
*Message.DEFAULT_SELECT_RELATED
|
||||||
|
)
|
||||||
|
|
||||||
update_fields = ["edit_history", "last_edit_time"]
|
update_fields = ["edit_history", "last_edit_time"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue