[PR #21019] [MERGED] perf: optimize database queries in functions, feedbacks, and groups #48939

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

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21019
Author: @Classic298
Created: 1/28/2026
Status: Merged
Merged: 1/29/2026
Merged by: @tjbck

Base: devHead: opt-queries


📝 Commits (1)

  • 100e8bf perf: optimize database queries in functions, feedbacks, and groups

📊 Changes

3 files changed (+12 additions, -20 deletions)

View changed files

📝 backend/open_webui/models/feedbacks.py (+4 -12)
📝 backend/open_webui/models/functions.py (+4 -3)
📝 backend/open_webui/models/groups.py (+4 -5)

📄 Description

Summary

Eliminates redundant database queries and loop-based operations across three model files.

Changes

models/functions.py

  • update_function_valves_by_id: Return refreshed object directly instead of re-fetching
  • update_function_metadata_by_id: Return refreshed object directly instead of re-fetching
  • update_function_by_id: Fetch once after commit instead of calling get_function_by_id

models/feedbacks.py

  • delete_feedbacks_by_user_id: Replace loop-based delete with single bulk delete
  • delete_all_feedbacks: Replace loop-based delete with single bulk delete

models/groups.py

  • remove_users_from_group: Replace loop delete with batch delete using IN clause

Performance Impact

  • functions.py: Saves 1 SELECT query per update operation
  • feedbacks.py: Reduces N DELETE statements to 1 for bulk operations
  • groups.py: Reduces N DELETE statements to 1 when removing multiple users

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/21019 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 1/28/2026 **Status:** ✅ Merged **Merged:** 1/29/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `opt-queries` --- ### 📝 Commits (1) - [`100e8bf`](https://github.com/open-webui/open-webui/commit/100e8bf1d7d52fbca994121d839e78051a012588) perf: optimize database queries in functions, feedbacks, and groups ### 📊 Changes **3 files changed** (+12 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/feedbacks.py` (+4 -12) 📝 `backend/open_webui/models/functions.py` (+4 -3) 📝 `backend/open_webui/models/groups.py` (+4 -5) </details> ### 📄 Description ## Summary Eliminates redundant database queries and loop-based operations across three model files. ## Changes ### models/functions.py - update_function_valves_by_id: Return refreshed object directly instead of re-fetching - update_function_metadata_by_id: Return refreshed object directly instead of re-fetching - update_function_by_id: Fetch once after commit instead of calling get_function_by_id ### models/feedbacks.py - delete_feedbacks_by_user_id: Replace loop-based delete with single bulk delete - delete_all_feedbacks: Replace loop-based delete with single bulk delete ### models/groups.py - remove_users_from_group: Replace loop delete with batch delete using IN clause ## Performance Impact - functions.py: Saves 1 SELECT query per update operation - feedbacks.py: Reduces N DELETE statements to 1 for bulk operations - groups.py: Reduces N DELETE statements to 1 when removing multiple users ### Contributor License Agreement 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:10:17 -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#48939