[PR #22301] [MERGED] perf(models): batch-fetch function valves to eliminate N+1 queries #49647

Closed
opened 2026-04-30 01:57:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 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: devHead: perf/batch-action-valves


📝 Commits (4)

📊 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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22301 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `perf/batch-action-valves` --- ### 📝 Commits (4) - [`ca09c3f`](https://github.com/open-webui/open-webui/commit/ca09c3fc9233d34d41701440de85c00355a1cf5a) perf(models): batch-fetch function valves to eliminate N+1 queries - [`50b4036`](https://github.com/open-webui/open-webui/commit/50b40365e46e8ffdc61feecc7af883f4b6ebf842) Update models.py - [`fcee980`](https://github.com/open-webui/open-webui/commit/fcee980c5e5471997d8082ce2a8bf5397deb3a59) Update models.py - [`b152561`](https://github.com/open-webui/open-webui/commit/b152561597c77b264d1d63bbd34596462754bfb5) Merge 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) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/functions.py` (+25 -0) 📝 `backend/open_webui/utils/models.py` (+7 -1) </details> ### 📄 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 <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 01:57:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#49647