mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-14 04:08:46 +00:00
perf: speed up one-word chat search (#32268)
Chat search checks the whole query and each word in it separately. With a single word those are the same check, so every chat got searched twice. It is now searched once, with the same results. On PostgreSQL with 2164 chats (533 MB of chat data) a one-word search is about 40% faster: | search | before | after | |---|---|---| | proxy | 6.0 s | 3.6 s | | opnsense | 6.1 s | 3.8 s | | no match | 5.4 s | 3.0 s | Refs #32266
This commit is contained in:
parent
80ae7f620a
commit
113a64ad1a
1 changed files with 2 additions and 1 deletions
|
|
@ -2180,7 +2180,8 @@ class ChatTable:
|
|||
search_text_words = [word for word in search_text_words if not word.startswith(CHAT_SEARCH_FILTER_PREFIXES)]
|
||||
|
||||
phrase_query = ' '.join(search_text_words).strip()
|
||||
search_terms = chat_search_terms(phrase_query)
|
||||
# A single-word query is already fully covered by the phrase match
|
||||
search_terms = [term for term in chat_search_terms(phrase_query) if term != phrase_query]
|
||||
|
||||
async with get_async_db_context(db) as session:
|
||||
stmt = select(Chat).filter(Chat.user_id == user_id)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue