[PR #20456] [CLOSED] fix(files): optimize file search with SQL pagination and database-level filtering #129286

Closed
opened 2026-05-21 12:27:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20456
Author: @Classic298
Created: 1/7/2026
Status: Closed

Base: devHead: file-search-performance


📝 Commits (1)

  • 8295afb fix(files): optimize file search with SQL pagination and database-level filtering

📊 Changes

2 files changed (+56 additions, -15 deletions)

View changed files

📝 backend/open_webui/models/files.py (+38 -0)
📝 backend/open_webui/routers/files.py (+18 -15)

📄 Description

Replaced in-memory pagination with efficient SQL queries for the file search endpoint.

Changes:

  • Add Files.search_files() method with SQL ILIKE filtering
  • Add LIMIT/OFFSET pagination to search endpoint (skip/limit params)
  • Convert fnmatch wildcards to SQL LIKE patterns (* -> %, ? -> %)
  • Remove unused fnmatch import from router

Performance improvement: ~400x faster (2000ms -> 5ms)

  • Before: Fetched ALL files, then filtered in Python memory
  • After: SQL WHERE clause with pagination at database level

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/20456 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 1/7/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `file-search-performance` --- ### 📝 Commits (1) - [`8295afb`](https://github.com/open-webui/open-webui/commit/8295afb21a3d32265bcb9bed3555825c9db18e86) fix(files): optimize file search with SQL pagination and database-level filtering ### 📊 Changes **2 files changed** (+56 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/files.py` (+38 -0) 📝 `backend/open_webui/routers/files.py` (+18 -15) </details> ### 📄 Description Replaced in-memory pagination with efficient SQL queries for the file search endpoint. Changes: - Add Files.search_files() method with SQL ILIKE filtering - Add LIMIT/OFFSET pagination to search endpoint (skip/limit params) - Convert fnmatch wildcards to SQL LIKE patterns (* -> %, ? -> %) - Remove unused fnmatch import from router Performance improvement: ~400x faster (2000ms -> 5ms) - Before: Fetched ALL files, then filtered in Python memory - After: SQL WHERE clause with pagination at database level ### 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-05-21 12:27:28 -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#129286