mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-21 00:52:24 -05:00
[PR #20427] [MERGED] fix: resolve N+1 query pattern in users endpoint #112933
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/20427
Author: @Classic298
Created: 1/6/2026
Status: ✅ Merged
Merged: 1/6/2026
Merged by: @tjbck
Base:
dev← Head:n+1📝 Commits (1)
ca508b0fix: resolve N+1 query pattern in users endpoint📊 Changes
2 files changed (+26 additions, -4 deletions)
View changed files
📝
backend/open_webui/models/groups.py(+21 -0)📝
backend/open_webui/routers/users.py(+5 -4)📄 Description
Summary
Fixed N+1 query pattern in the
/api/v1/usersendpoint where groups were being fetched for each user individually.Problem
The
GET /api/v1/usersendpoint calledGroups.get_groups_by_member_id()for each user, resulting in:Solution
Added a new
Groups.get_groups_by_member_ids()method that fetches groups for multiple users in a single query using SQLINclause andJOIN.Result
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.