update_first_visible_message_id: Use Message.realm column.

With the Message.realm column added, this query can now be improved.
This commit is contained in:
Mateusz Mandera 2022-10-28 21:05:40 +02:00 committed by Tim Abbott
parent 925fa4ca50
commit 601f0677f3
1 changed files with 1 additions and 1 deletions

View File

@ -1437,7 +1437,7 @@ def update_first_visible_message_id(realm: Realm) -> None:
else: else:
try: try:
first_visible_message_id = ( first_visible_message_id = (
Message.objects.filter(sender__realm=realm) Message.objects.filter(realm=realm)
.values("id") .values("id")
.order_by("-id")[realm.message_visibility_limit - 1]["id"] .order_by("-id")[realm.message_visibility_limit - 1]["id"]
) )