perf(chats): drop redundant db.refresh after commit in update_chat_by_id (#24024)

The chat table has no computed columns (no DEFAULT, SERIAL/IDENTITY,
or TRIGGER that populate server-side values on UPDATE), and every
column modified by update_chat_by_id is set explicitly from Python
values earlier in the function. db.refresh therefore issues a SELECT
that replaces those just-written Python values with the round-tripped
database representation of the same values, which is a no-op for
functional purposes but pulls the entire chat.chat JSON blob back over
the network and through the driver's JSON decoder.

On large, active chats where chat.chat can reach tens of megabytes,
skipping the refresh measurably reduces latency and eliminates one
~JSON-sized transient allocation per write.
This commit is contained in:
Constantine
2026-04-24 12:34:57 +03:00
committed by GitHub
parent 3aeb691d98
commit 3560d2f630

View File

@@ -393,7 +393,6 @@ class ChatTable:
chat_item.updated_at = int(time.time())
await db.commit()
await db.refresh(chat_item)
return ChatModel.model_validate(chat_item)
except Exception: