[PR #21005] [MERGED] perf: resolve N+1 query in SCIM group_to_scim user lookup #113190

Closed
opened 2026-05-18 13:30:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21005
Author: @Classic298
Created: 1/28/2026
Status: Merged
Merged: 1/29/2026
Merged by: @tjbck

Base: devHead: scim-1


📝 Commits (1)

  • fd94b12 fix: resolve N+1 query in SCIM group_to_scim user lookup

📊 Changes

1 file changed (+11 additions, -12 deletions)

View changed files

📝 backend/open_webui/routers/scim.py (+11 -12)

📄 Description

Summary

Eliminates N+1 database query in SCIM group_to_scim function. Previously, when converting a group to SCIM format, each member's user was fetched individually.

Changes

routers/scim.py group_to_scim function:

  • Replace loop calling get_user_by_id per member
  • Use single get_users_by_user_ids batch call

Performance Impact

Before: N+1 queries (1 per group member)
After: 1 query total using SQL IN clause

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/21005 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 1/28/2026 **Status:** ✅ Merged **Merged:** 1/29/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `scim-1` --- ### 📝 Commits (1) - [`fd94b12`](https://github.com/open-webui/open-webui/commit/fd94b12ab4d671f4e6b26591f1f3d36ad1988246) fix: resolve N+1 query in SCIM group_to_scim user lookup ### 📊 Changes **1 file changed** (+11 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/scim.py` (+11 -12) </details> ### 📄 Description ## Summary Eliminates N+1 database query in SCIM group_to_scim function. Previously, when converting a group to SCIM format, each member's user was fetched individually. ## Changes routers/scim.py group_to_scim function: - Replace loop calling get_user_by_id per member - Use single get_users_by_user_ids batch call ## Performance Impact Before: N+1 queries (1 per group member) After: 1 query total using SQL IN clause ### 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-18 13:30: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#113190