mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #4046] [MERGED] perf: optimize query for chat list #44438
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/4046
Author: @thearyadev
Created: 7/22/2024
Status: ✅ Merged
Merged: 7/24/2024
Merged by: @tjbck
Base:
dev← Head:chat-list-optimization📝 Commits (3)
2b78e61add func to get chat list with more specific sql querya0667dfchange/chats/and/chats/listto utilize new functionf531a51chore: formatting📊 Changes
2 files changed (+35 additions, -1 deletions)
View changed files
📝
backend/apps/webui/models/chats.py(+34 -0)📝
backend/apps/webui/routers/chats.py(+1 -1)📄 Description
Changelog Entry
Description
Performance issue #4035 has additional details.
This PR optimizes the query made to the database by selecting only the required columns.
The images which are stored in the database chat history make the slow down apparent when querying that endpoint, which happens on every reload.
This change will allow for significantly improved performance with large database sizes.
This PR doesn't solve the root issue, as the issue is caused by excessive database size.
Added
/chatsendpoint, which only queries the fields it needsChanged
/chatsand/chats/listendpoints to use the new function.skip: intwas passed as a positional argument to the function parameterinclude_archived: boolchanged to
using keyword arguments to safely pass the params.
Screenshots or Videos
test done with 500mb database, artificially bloated with images
before optimization
https://github.com/user-attachments/assets/16419820-adbe-4b8b-85ec-391dbfdfb129
after optimization
https://github.com/user-attachments/assets/4f0bdd5b-7ab1-438e-bff4-64fa5d530e0c
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.