mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #17162] [MERGED] perf: fix N+1 query issue in get_tools method #39971
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/17162
Author: @sihyeonn
Created: 9/2/2025
Status: ✅ Merged
Merged: 9/3/2025
Merged by: @tjbck
Base:
dev← Head:perf/sh-tools📝 Commits (1)
03d1d2aperf: fix N+1 query issue in get_tools method📊 Changes
1 file changed (+9 additions, -2 deletions)
View changed files
📝
backend/open_webui/models/tools.py(+9 -2)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Fixed a critical N+1 query performance issue in the
get_toolsmethod where user information was being fetched individually for each tool. This optimization repletes multiple individual user queries with a single batch query, significantly improving database performance and reducing query load.This completes the comprehensive N+1 query optimization across all major listing endpoints (prompts, knowledge bases, models, and tools), ensuring consistent performance improvements throughout the application.
Changed
get_toolsmethod inToolsTableclass to use batch user fetchingFixed
Additional Information
backend/open_webui/models/tools.py(lines 145-165)1 + Nqueries to1 + 1queriesContributor 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.