5387bf3 perf: Optimize user_count query for licensed-seats banner
📊 Changes
1 file changed (+14 additions, -4 deletions)
View changed files
📝backend/open_webui/main.py (+14 -4)
📄 Description
Description
This PR optimizes the get_app_config endpoint to avoid unnecessary full table scans when counting users. The user_count is only consumed by the licensed-seats banner, so we now skip the expensive get_num_users() query unless a seat-limited license is actually configured.
Changes
Replace get_num_users() call for onboarding detection with a more efficient has_users() check
Conditionally fetch user_count only when:
User is authenticated
User has admin or user role
A seat-limited license is configured
Conditionally include user_count in response only when it has been fetched
This reduces unnecessary database queries on every config request for instances without seat-limited licenses.
Fixed
Reduced unnecessary database queries in get_app_config endpoint
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/24904
**Author:** [@Classic298](https://github.com/Classic298)
**Created:** 5/19/2026
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `perf_db_counts`
---
### 📝 Commits (1)
- [`5387bf3`](https://github.com/open-webui/open-webui/commit/5387bf36c299a88400f9660d13dc672415ece20e) perf: Optimize user_count query for licensed-seats banner
### 📊 Changes
**1 file changed** (+14 additions, -4 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/main.py` (+14 -4)
</details>
### 📄 Description
# Description
This PR optimizes the `get_app_config` endpoint to avoid unnecessary full table scans when counting users. The `user_count` is only consumed by the licensed-seats banner, so we now skip the expensive `get_num_users()` query unless a seat-limited license is actually configured.
## Changes
- Replace `get_num_users()` call for onboarding detection with a more efficient `has_users()` check
- Conditionally fetch `user_count` only when:
- User is authenticated
- User has admin or user role
- A seat-limited license is configured
- Conditionally include `user_count` in response only when it has been fetched
This reduces unnecessary database queries on every config request for instances without seat-limited licenses.
### Fixed
- Reduced unnecessary database queries in `get_app_config` endpoint
### Contributor License Agreement
<!--
🚨 DO NOT DELETE THE TEXT BELOW 🚨
Keep the "Contributor License Agreement" confirmation text intact.
Deleting it will trigger the CLA-Bot to INVALIDATE your PR.
Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA.
-->
- [x] 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/24904
Author: @Classic298
Created: 5/19/2026
Status: ❌ Closed
Base:
dev← Head:perf_db_counts📝 Commits (1)
5387bf3perf: Optimize user_count query for licensed-seats banner📊 Changes
1 file changed (+14 additions, -4 deletions)
View changed files
📝
backend/open_webui/main.py(+14 -4)📄 Description
Description
This PR optimizes the
get_app_configendpoint to avoid unnecessary full table scans when counting users. Theuser_countis only consumed by the licensed-seats banner, so we now skip the expensiveget_num_users()query unless a seat-limited license is actually configured.Changes
get_num_users()call for onboarding detection with a more efficienthas_users()checkuser_countonly when:user_countin response only when it has been fetchedThis reduces unnecessary database queries on every config request for instances without seat-limited licenses.
Fixed
get_app_configendpointContributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.