open-webui/backend/open_webui
Classic298 b3ca943da1
perf(channels): batch user lookup in model_response_handler thread history (#23795)
* perf(channels): batch user lookup in model_response_handler thread history

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().

* refac(channels): rename loop vars to full words per review

Address reviewer feedback to use descriptive names `message` and `user`
instead of single-letter `m` and `u` in the batch user-lookup
comprehensions.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-20 08:37:07 +09:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac 2026-04-17 11:27:58 +09:00
migrations chore: format 2026-04-19 22:45:54 +09:00
models refac 2026-04-20 00:07:34 +09:00
retrieval refac 2026-04-20 08:34:15 +09:00
routers perf(channels): batch user lookup in model_response_handler thread history (#23795) 2026-04-20 08:37:07 +09:00
socket refac 2026-04-17 13:29:51 +09:00
static chore: format 2026-04-19 22:45:54 +09:00
storage refac 2026-04-12 19:08:30 -05:00
test refac 2026-03-17 17:58:01 -05:00
tools refac 2026-04-19 23:42:09 +09:00
utils refac 2026-04-20 08:34:15 +09:00
__init__.py refac (#22987) 2026-03-24 15:41:26 -05:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py chore: format 2026-04-19 22:45:54 +09:00
constants.py chore: format 2026-04-14 17:27:31 -05:00
env.py refac 2026-04-17 11:27:58 +09:00
functions.py refac 2026-04-17 14:15:36 +09:00
main.py refac 2026-04-19 23:38:58 +09:00
tasks.py refac 2026-03-17 17:58:01 -05:00