[PR #24287] [MERGED] perf: make /tags fetch only the tags column with SQL access filter #98624

Closed
opened 2026-05-16 01:26:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24287
Author: @Classic298
Created: 5/1/2026
Status: Merged
Merged: 5/8/2026
Merged by: @tjbck

Base: devHead: perf/prompts-tags-query


📝 Commits (1)

  • 95f7fd2 perf(prompts): make /tags fetch only the tags column with SQL access filter

📊 Changes

2 files changed (+32 additions, -12 deletions)

View changed files

📝 backend/open_webui/models/prompts.py (+31 -5)
📝 backend/open_webui/routers/prompts.py (+1 -7)

📄 Description

Fixes : https://github.com/open-webui/open-webui/discussions/24258

Non-admin GET /api/v1/prompts/tags went through get_prompts_by_user_id, which loaded every active prompt with its full content/data/meta plus owner records and all access grants, then ran one has_access query per prompt that wasn't owned by the caller - all so the endpoint could collapse the result to a sorted tag list. With 600 prompts this took several seconds while the admin path (a single SELECT) returned in <1s.

Add Prompts.get_tags_by_user_id which selects only the tags column and applies the same EXISTS-based access filter used by /list. Also tighten the admin get_tags to project just the tags column instead of full rows. The endpoint is now one DB query (plus one for groups), no row hydration, no N+1.

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/24287 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 5/1/2026 **Status:** ✅ Merged **Merged:** 5/8/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `perf/prompts-tags-query` --- ### 📝 Commits (1) - [`95f7fd2`](https://github.com/open-webui/open-webui/commit/95f7fd2232d42bd4cf278af0c030e7f5f59bd21a) perf(prompts): make /tags fetch only the tags column with SQL access filter ### 📊 Changes **2 files changed** (+32 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/prompts.py` (+31 -5) 📝 `backend/open_webui/routers/prompts.py` (+1 -7) </details> ### 📄 Description Fixes : https://github.com/open-webui/open-webui/discussions/24258 Non-admin GET /api/v1/prompts/tags went through get_prompts_by_user_id, which loaded every active prompt with its full content/data/meta plus owner records and all access grants, then ran one has_access query per prompt that wasn't owned by the caller - all so the endpoint could collapse the result to a sorted tag list. With 600 prompts this took several seconds while the admin path (a single SELECT) returned in <1s. Add Prompts.get_tags_by_user_id which selects only the tags column and applies the same EXISTS-based access filter used by /list. Also tighten the admin get_tags to project just the tags column instead of full rows. The endpoint is now one DB query (plus one for groups), no row hydration, no N+1. ### 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-16 01:26:00 -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#98624