mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:24:24 -05:00
[PR #23795] [MERGED] perf(channels): batch user lookup in model_response_handler thread history #131038
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23795
Author: @Classic298
Created: 4/16/2026
Status: ✅ Merged
Merged: 4/19/2026
Merged by: @tjbck
Base:
dev← Head:claude/fix-channels-messages-n-plus-1📝 Commits (2)
968df81perf(channels): batch user lookup in model_response_handler thread history9e480b1refac(channels): rename loop vars to full words per review📊 Changes
1 file changed (+5 additions, -7 deletions)
View changed files
📝
backend/open_webui/routers/channels.py(+5 -7)📄 Description
The thread-history builder in model_response_handler called Users.get_user_by_id once per thread message (deduped via an intra-loop dict), producing N individual SELECTs for a thread of N unique authors.
Replace with a single Users.get_users_by_user_ids call that returns all authors in one WHERE id IN (...) query, matching the batch pattern already used elsewhere in this file (lines 739, 804, 1320).
Behavior is preserved: deleted users still resolve to None and fall through to the existing 'Unknown' fallback via .get().
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.