mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
[PR #22301] [MERGED] perf(models): batch-fetch function valves to eliminate N+1 queries #49647
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/22301
Author: @Classic298
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @tjbck
Base:
dev← Head:perf/batch-action-valves📝 Commits (4)
ca09c3fperf(models): batch-fetch function valves to eliminate N+1 queries50b4036Update models.pyfcee980Update models.pyb152561Merge branch 'perf/batch-action-valves' of https://github.com/Classic298/open-webui into perf/batch-action-valves📊 Changes
2 files changed (+32 additions, -1 deletions)
View changed files
📝
backend/open_webui/models/functions.py(+25 -0)📝
backend/open_webui/utils/models.py(+7 -1)📄 Description
get_action_priority() called Functions.get_function_valves_by_id() individually for every action on every model — an N+1 query pattern that issued one DB round-trip per (action x model) pair.
Add Functions.get_function_valves_by_ids() that fetches all valves in a single WHERE IN query, then look up each action's valves from the pre-fetched dict inside get_action_priority().
No functional change — same priority resolution, same sort order.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.