2434bb4 perf: eliminate redundant SELECT after UPDATE in users.py
📊 Changes
1 file changed (+27 additions, -21 deletions)
View changed files
📝backend/open_webui/models/users.py (+27 -21)
📄 Description
Summary
Eliminates redundant database queries in 5 update methods in users.py. Previously, each method called update() followed by a separate query().first() to return the updated object.
Changes
models/users.py - 5 methods updated to use fetch-modify-refresh pattern:
update_user_role_by_id
update_user_status_by_id
update_user_profile_image_url_by_id
update_last_active_by_id
update_user_by_id
Each method now:
Fetches user once
Modifies in place
Commits and refreshes
Returns the same object
Performance Impact
Before: 2 queries per update (UPDATE + SELECT)
After: 1 query + commit + refresh on same object
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/21011
**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:** `user-select`
---
### 📝 Commits (1)
- [`2434bb4`](https://github.com/open-webui/open-webui/commit/2434bb400df0297f329f8178635ec2c781179b01) perf: eliminate redundant SELECT after UPDATE in users.py
### 📊 Changes
**1 file changed** (+27 additions, -21 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/models/users.py` (+27 -21)
</details>
### 📄 Description
## Summary
Eliminates redundant database queries in 5 update methods in users.py. Previously, each method called update() followed by a separate query().first() to return the updated object.
## Changes
models/users.py - 5 methods updated to use fetch-modify-refresh pattern:
- update_user_role_by_id
- update_user_status_by_id
- update_user_profile_image_url_by_id
- update_last_active_by_id
- update_user_by_id
Each method now:
1. Fetches user once
2. Modifies in place
3. Commits and refreshes
4. Returns the same object
## Performance Impact
Before: 2 queries per update (UPDATE + SELECT)
After: 1 query + commit + refresh on same object
### 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/21011
Author: @Classic298
Created: 1/28/2026
Status: ✅ Merged
Merged: 1/29/2026
Merged by: @tjbck
Base:
dev← Head:user-select📝 Commits (1)
2434bb4perf: eliminate redundant SELECT after UPDATE in users.py📊 Changes
1 file changed (+27 additions, -21 deletions)
View changed files
📝
backend/open_webui/models/users.py(+27 -21)📄 Description
Summary
Eliminates redundant database queries in 5 update methods in users.py. Previously, each method called update() followed by a separate query().first() to return the updated object.
Changes
models/users.py - 5 methods updated to use fetch-modify-refresh pattern:
Each method now:
Performance Impact
Before: 2 queries per update (UPDATE + SELECT)
After: 1 query + commit + refresh on same object
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.