mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-14 23:22:44 +00:00
perf: eliminate redundant query after memory update (#21013)
## Summary Eliminates redundant database query in update_memory_by_id_and_user_id. Previously, after modifying the memory object, it called get_memory_by_id which opened a new session and queried again. ## Changes models/memories.py update_memory_by_id_and_user_id: - Replace self.get_memory_by_id(id) with db.refresh(memory) - Return the same memory object that was already modified ## Performance Impact Before: 2 queries (get + get_memory_by_id) After: 1 query + refresh on same session
This commit is contained in:
parent
68e257849d
commit
baef422a28
1 changed files with 2 additions and 1 deletions
|
|
@ -82,7 +82,8 @@ class MemoriesTable:
|
|||
memory.updated_at = int(time.time())
|
||||
|
||||
db.commit()
|
||||
return self.get_memory_by_id(id)
|
||||
db.refresh(memory)
|
||||
return MemoryModel.model_validate(memory)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue