open-webui/backend/open_webui/models
Classic298 41107a34ca
perf(prompts): filter prompt list in SQL instead of N+1 has_access loop (#24288)
get_prompts_by_user_id used to fetch every active prompt (with users +
all access grants), then call AccessGrants.has_access() once per prompt
that the user did not own. With 600+ prompts this issued ~600 extra
round-trips per request and explained the multi-second delay reported in
the GET /api/v1/prompts and /api/v1/prompts/tags endpoints for non-admin
users.

Push the access check into a single SQL query via the existing
AccessGrants.has_permission_filter (EXISTS subquery), so only accessible
rows come back from the DB. Users and access grants for the surviving
rows are still batch-fetched, no N+1 anywhere on this path.

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-09 05:12:51 +09:00
..
access_grants.py chore: format 2026-04-12 18:12:59 -05:00
auths.py chore: format 2026-04-12 18:12:59 -05:00
automations.py chore: format 2026-04-19 22:45:54 +09:00
calendar.py chore: format 2026-04-21 15:52:00 +09:00
channels.py Apply validate_profile_image_url to ChannelWebhookForm.profile_image_url (#24370) 2026-05-09 03:19:25 +09:00
chat_messages.py refac 2026-05-05 04:21:23 +09:00
chats.py refac 2026-05-09 03:19:48 +09:00
feedbacks.py chore: format 2026-04-12 18:12:59 -05:00
files.py chore: format 2026-04-12 18:12:59 -05:00
folders.py fix: drop extra='allow' on FolderForm and FolderUpdateForm (#23648) 2026-04-13 16:14:00 -05:00
functions.py chore: format 2026-04-12 18:12:59 -05:00
groups.py chore: format 2026-04-12 18:12:59 -05:00
knowledge.py chore: format 2026-04-12 18:12:59 -05:00
memories.py refac: async db 2026-04-12 14:22:11 -05:00
messages.py chore: format 2026-04-12 18:12:59 -05:00
models.py chore: format 2026-04-24 18:48:21 +09:00
notes.py refac 2026-05-09 04:39:44 +09:00
oauth_sessions.py chore: format 2026-04-24 18:48:21 +09:00
prompt_history.py refac: async db 2026-04-12 14:22:11 -05:00
prompts.py perf(prompts): filter prompt list in SQL instead of N+1 has_access loop (#24288) 2026-05-09 05:12:51 +09:00
shared_chats.py chore: format 2026-04-17 14:28:18 +09:00
skills.py chore: format 2026-04-12 18:12:59 -05:00
tags.py chore: format 2026-04-12 18:12:59 -05:00
tools.py chore: format 2026-04-12 18:12:59 -05:00
users.py refac 2026-04-12 18:49:34 -05:00