[PR #24904] [CLOSED] perf: Optimize user_count query for licensed-seats banner #131584

Closed
opened 2026-05-21 17:16:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 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)

  • 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

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>
GiteaMirror added the pull-request label 2026-05-21 17:16:11 -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#131584