Note to first-time contributors
Please open a discussion post in Discussions to discuss your idea or fix with the community before creating a pull request.
This ensures that large feature PRs are aligned with the project goals and avoids unnecessary work if the feature is not desired.
Pre-Submission Checklist
Before submitting your pull request, please confirm the following:
Target Branch
This pull request targets the dev branch
Not targeting dev will lead to immediate closure
Description
A concise description of the changes is provided below
Changelog
A changelog entry following Keep a Changelog format is included at the bottom of the PR description
Documentation
Relevant documentation has been updated (Open WebUI Docs, environment variables, tutorials, etc.)
Dependencies
Any new dependencies are documented
Dependency version changes are reflected in the documentation
Testing
Manual testing has been performed
The change works as intended and does not break existing functionality
Screenshots are included where applicable
Agentic AI Code
This PR was not written solely by an AI agent
If AI was used, the code has undergone human review and manual testing
AI-only PRs may be closed immediately
Code Review
A self-review has been completed
Code follows the project’s coding standards
Pull Request Title Prefix
Prefix your pull request title with one of the following:
BREAKING CHANGE: Compatibility-impacting changes
build: Build system or dependency changes
ci: CI workflow updates
chore: Cleanup or non-functional changes
docs: Documentation updates
feat: New features or enhancements
fix: Bug fixes
i18n: Internationalization or localization
perf: Performance improvements
refactor: Code restructuring
style: Formatting or stylistic changes
test: Test additions or corrections
WIP: Work in progress
Changes Made
get_groups() Method
Before
Queried all groups
Executed get_group_member_count_by_id() for each group
Resulted in N+1 queries
After
Uses a single query with:
LEFT OUTER JOIN on GroupMember
func.count() aggregation
Retrieves member counts in one database round-trip
search_groups() Method
Before
Same N+1 query pattern during pagination
After
Single aggregated query
Member counts included
Pagination (offset / limit) preserved
Performance Impact
Database round-trips:N + 1 → 1
Query complexity:O(N+1) → O(1)
Real-world impact: Retrieving 100 groups now executes 1 query instead of 101
Contributor License Agreement (CLA)
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.
⚠️Important:
Deleting this CLA section will lead to immediate closure of the PR.
🔄 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/21154
**Author:** [@ylwy0178-ctrl](https://github.com/ylwy0178-ctrl)
**Created:** 2/4/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `bugfix/get_all_group_query_optimization`
---
### 📝 Commits (1)
- [`e2ea4a7`](https://github.com/open-webui/open-webui/commit/e2ea4a780f12527de73987b636065925b9fe0c37) Update groups.py
### 📊 Changes
**1 file changed** (+30 additions, -17 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/models/groups.py` (+30 -17)
</details>
### 📄 Description
# Pull Request Checklist
> **Note to first-time contributors**
> Please open a discussion post in **Discussions** to discuss your idea or fix with the community before creating a pull request.
>
> This ensures that large feature PRs are aligned with the project goals and avoids unnecessary work if the feature is not desired.
---
## Pre-Submission Checklist
Before submitting your pull request, please confirm the following:
- **Target Branch**
- [ ] This pull request targets the **`dev`** branch
- [ ] Not targeting `dev` will lead to immediate closure
- **Description**
- [ ] A concise description of the changes is provided below
- **Changelog**
- [ ] A changelog entry following **Keep a Changelog** format is included at the bottom of the PR description
- **Documentation**
- [ ] Relevant documentation has been updated (Open WebUI Docs, environment variables, tutorials, etc.)
- **Dependencies**
- [ ] Any new dependencies are documented
- [ ] Dependency version changes are reflected in the documentation
- **Testing**
- [ ] Manual testing has been performed
- [ ] The change works as intended and does not break existing functionality
- [ ] Screenshots are included where applicable
- **Agentic AI Code**
- [ ] This PR was not written solely by an AI agent
- [ ] If AI was used, the code has undergone human review and manual testing
- AI-only PRs may be closed immediately
- **Code Review**
- [ ] A self-review has been completed
- [ ] Code follows the project’s coding standards
---
## Pull Request Title Prefix
Prefix your pull request title with **one** of the following:
- `BREAKING CHANGE:` Compatibility-impacting changes
- `build:` Build system or dependency changes
- `ci:` CI workflow updates
- `chore:` Cleanup or non-functional changes
- `docs:` Documentation updates
- `feat:` New features or enhancements
- `fix:` Bug fixes
- `i18n:` Internationalization or localization
- `perf:` Performance improvements
- `refactor:` Code restructuring
- `style:` Formatting or stylistic changes
- `test:` Test additions or corrections
- `WIP:` Work in progress
---
## Changes Made
### `get_groups()` Method
**Before**
- Queried all groups
- Executed `get_group_member_count_by_id()` for each group
- Resulted in **N+1 queries**
**After**
- Uses a single query with:
- `LEFT OUTER JOIN` on `GroupMember`
- `func.count()` aggregation
- Retrieves member counts in one database round-trip
---
### `search_groups()` Method
**Before**
- Same N+1 query pattern during pagination
**After**
- Single aggregated query
- Member counts included
- Pagination (`offset` / `limit`) preserved
---
## Performance Impact
- **Database round-trips:** `N + 1` → `1`
- **Query complexity:** `O(N+1)` → `O(1)`
- **Real-world impact:** Retrieving 100 groups now executes **1 query instead of 101**
---
# Contributor License Agreement (CLA)
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.
> ⚠️ **Important:**
> Deleting this CLA section will lead to immediate closure of the PR.
---
<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/21154
Author: @ylwy0178-ctrl
Created: 2/4/2026
Status: ❌ Closed
Base:
main← Head:bugfix/get_all_group_query_optimization📝 Commits (1)
e2ea4a7Update groups.py📊 Changes
1 file changed (+30 additions, -17 deletions)
View changed files
📝
backend/open_webui/models/groups.py(+30 -17)📄 Description
Pull Request Checklist
Pre-Submission Checklist
Before submitting your pull request, please confirm the following:
Target Branch
devbranchdevwill lead to immediate closureDescription
Changelog
Documentation
Dependencies
Testing
Agentic AI Code
Code Review
Pull Request Title Prefix
Prefix your pull request title with one of the following:
BREAKING CHANGE:Compatibility-impacting changesbuild:Build system or dependency changesci:CI workflow updateschore:Cleanup or non-functional changesdocs:Documentation updatesfeat:New features or enhancementsfix:Bug fixesi18n:Internationalization or localizationperf:Performance improvementsrefactor:Code restructuringstyle:Formatting or stylistic changestest:Test additions or correctionsWIP:Work in progressChanges Made
get_groups()MethodBefore
get_group_member_count_by_id()for each groupAfter
LEFT OUTER JOINonGroupMemberfunc.count()aggregationsearch_groups()MethodBefore
After
offset/limit) preservedPerformance Impact
N + 1→1O(N+1)→O(1)Contributor License Agreement (CLA)
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.