open-webui/backend/open_webui
G30 e69ce6e1c6
perf(channels): batch N+1 queries for reactions and thread replies (#25831)
Replace per-message database queries with batch IN-clause queries in
channel message handlers. This eliminates the N+1 query pattern that
caused ~102 queries per channel page load (50 messages × 2 queries each).

Changes:
- Add get_reactions_by_message_ids() to MessageTable: single query
  fetches all reactions for multiple messages using IN clause with
  User JOIN, returns dict[message_id, list[Reactions]]
- Add get_thread_reply_counts_by_message_ids() to MessageTable: single
  GROUP BY aggregate query returns (count, max_created_at) per parent,
  replacing full object loads just to call len()
- Refactor get_channel_messages(): 102 → 4 queries per page
- Refactor get_pinned_channel_messages(): 22 → 3 queries per page
- Refactor get_channel_thread_messages(): 53 → 4 queries per page
- Refactor send_notification(): N+1 membership check → batch set lookup
2026-06-29 02:05:16 -05:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac 2026-06-17 02:52:35 +02:00
migrations refac 2026-06-29 00:21:37 -05:00
models perf(channels): batch N+1 queries for reactions and thread replies (#25831) 2026-06-29 02:05:16 -05:00
retrieval refac 2026-06-29 02:03:58 -05:00
routers perf(channels): batch N+1 queries for reactions and thread replies (#25831) 2026-06-29 02:05:16 -05:00
socket Require auth on ydoc:awareness:update and ydoc:document:leave handlers (CWE-306) (#25946) 2026-06-17 00:06:13 +02:00
static chore: format 2026-06-01 14:10:40 -07:00
storage refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tools refac 2026-06-29 00:46:45 -05:00
utils refac 2026-06-29 01:01:27 -05:00
__init__.py refac 2026-06-17 03:01:11 +02:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-06-29 01:52:07 -05:00
constants.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
env.py refac 2026-06-28 23:02:38 -05:00
events.py refac 2026-06-25 15:56:10 +01:00
functions.py fix: emit [DONE] for AsyncGenerator pipe returns (#24763) 2026-05-19 22:07:56 +04:00
main.py refac 2026-06-29 00:40:28 -05:00
tasks.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00