[PR #23795] [MERGED] perf(channels): batch user lookup in model_response_handler thread history #114682

Closed
opened 2026-05-18 15:29:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 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: devHead: claude/fix-channels-messages-n-plus-1


📝 Commits (2)

  • 968df81 perf(channels): batch user lookup in model_response_handler thread history
  • 9e480b1 refac(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

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/23795 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 4/16/2026 **Status:** ✅ Merged **Merged:** 4/19/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `claude/fix-channels-messages-n-plus-1` --- ### 📝 Commits (2) - [`968df81`](https://github.com/open-webui/open-webui/commit/968df8150a36820af1915e7677adc4724d372efa) perf(channels): batch user lookup in model_response_handler thread history - [`9e480b1`](https://github.com/open-webui/open-webui/commit/9e480b1757b2563a4ca2a85a3983c55329977e1e) refac(channels): rename loop vars to full words per review ### 📊 Changes **1 file changed** (+5 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/channels.py` (+5 -7) </details> ### 📄 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 <!-- 🚨 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-18 15:29:45 -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#114682