mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #19931] [CLOSED] perf: Knowledge has access to file improved #41027
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/19931
Author: @Classic298
Created: 12/13/2025
Status: ❌ Closed
Base:
dev← Head:optimize-file-access-check-8864712883276852158📝 Commits (7)
fe6783cMerge pull request #19030 from open-webui/devfc05e0aMerge pull request #19405 from open-webui/deve3faec6Merge pull request #19416 from open-webui/dev9899293Merge pull request #19448 from open-webui/dev140605eMerge pull request #19462 from open-webui/dev6f1486fMerge pull request #19466 from open-webui/dev4bb60b1Optimizehas_access_to_fileto prioritize directknowledge_filelookups📊 Changes
2 files changed (+35 additions, -15 deletions)
View changed files
📝
backend/open_webui/models/knowledge.py(+17 -0)📝
backend/open_webui/routers/files.py(+18 -15)📄 Description
Pull Request Checklist
Changelog Entry
Description
This change optimizes the
has_access_to_filefunction inbackend/open_webui/routers/files.pyto significantly improve performance.get_file_access_control_datawas added toKnowledgeTable. This method executes a targeted SQL query joining theknowledgeandknowledge_filetables to return only the necessaryuser_idandaccess_controlcolumns.Trueimmediately, skipping theFiles.get_file_by_idcall entirely. This saves a database round-trip in the most common success path.collection_namemetadata. The logic for checking this metadata was also optimized to fetch the specific knowledge base by ID (O(1)) rather than fetching all knowledge bases for the user and iterating (O(N)).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.