406a9ee fix(notes): eliminate N+1 query in get_notes endpoint
📊 Changes
1 file changed (+12 additions, -3 deletions)
View changed files
📝backend/open_webui/routers/notes.py (+12 -3)
📄 Description
Replaced per-note user lookup with batch fetch using SQL IN clause.
Changes:
Fetch all note user_ids in a single pass
Use Users.get_users_by_user_ids() for batch lookup
Build user mapping to avoid DB calls in loop
Performance: Reduces N+1 queries to 2 queries (notes + 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/20457
**Author:** [@Classic298](https://github.com/Classic298)
**Created:** 1/7/2026
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `notes-perf`
---
### 📝 Commits (1)
- [`406a9ee`](https://github.com/open-webui/open-webui/commit/406a9ee45ab35bf9dedcb423330ad19baf477575) fix(notes): eliminate N+1 query in get_notes endpoint
### 📊 Changes
**1 file changed** (+12 additions, -3 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/routers/notes.py` (+12 -3)
</details>
### 📄 Description
Replaced per-note user lookup with batch fetch using SQL IN clause.
Changes:
- Fetch all note user_ids in a single pass
- Use Users.get_users_by_user_ids() for batch lookup
- Build user mapping to avoid DB calls in loop
Performance: Reduces N+1 queries to 2 queries (notes + 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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20457
Author: @Classic298
Created: 1/7/2026
Status: ❌ Closed
Base:
dev← Head:notes-perf📝 Commits (1)
406a9eefix(notes): eliminate N+1 query in get_notes endpoint📊 Changes
1 file changed (+12 additions, -3 deletions)
View changed files
📝
backend/open_webui/routers/notes.py(+12 -3)📄 Description
Replaced per-note user lookup with batch fetch using SQL IN clause.
Changes:
Performance: Reduces N+1 queries to 2 queries (notes + 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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.