$ the-wire · showcase
Open WebUI cuts chat saves to one transaction
By RepoJournal · Filed · About Open WebUI
Saving a chat now writes all its messages in a single transaction, ending per-message session churn on every save.
Saving a chat in Open WebUI used to rewrite each message row with its own session and commit, so a two hundred message chat cost two hundred sessions and two hundred commits on every save. The messages now go through a single select and a single commit. This is a pure performance change; behavior and API are unchanged. [1]
Two more hot paths got the same treatment. Assembling builtin tools no longer re-reads the whole chat blob to check whether a chat is a note, since the caller had already loaded that row with the same predicate [2]. Model-attached file access checks now run the query in reverse, asking the database for models carrying the file id instead of scanning every accessible model's knowledge list in Python; a folder of twenty files no longer rebuilds the accessible-model set twenty times [3].
One fix changes behavior: a chat attached via the "+" menu or dropped from the sidebar references an existing chat by id and carries no url, so it was dropped from <attached_files> and the model never learned it existed. With the RAG file-context path disabled, that was entirely invisible; the reference is now surfaced in <attached_files>. The same commit also removes three unused KnowledgeTable accessors, one of which could only raise since it wrote a data column dropped by an earlier migration. [4][5]
Action items
- → Review your chat save path for potential performance gains and consider upgrading if you have large, frequently saved chats open-webui/open-webui [monitor]
References
- [1] perf: write a chat's messages in one transaction instead of one per message (#28806) ↗ open-webui/open-webui
- [2] perf: reuse the already loaded chat when assembling builtin tools (#28809) ↗ open-webui/open-webui
- [3] perf: resolve model-attached file access with a targeted query (#28802) ↗ open-webui/open-webui
- [4] fix: surface attached chat references in <attached_files> (#28788) ↗ open-webui/open-webui
- [5] refac: remove unused knowledge base accessors (#28794) ↗ open-webui/open-webui