open-webui/backend/open_webui/models
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
..
access_grants.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
auths.py refac 2026-06-17 00:43:59 +02:00
automations.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
calendar.py refac 2026-06-01 14:09:54 -07:00
channels.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
chat_messages.py refac 2026-06-23 23:35:44 +02:00
chats.py refac 2026-06-29 01:38:41 -05:00
config.py refac 2026-06-18 11:02:14 +02:00
feedbacks.py refac 2026-06-17 00:17:48 +02:00
files.py feat(ui): show total file count in FilesModal title (#25873) 2026-06-17 02:55:13 +02:00
folders.py refac 2026-06-17 00:25:35 +02:00
functions.py chore: format 2026-06-01 13:56:55 -07:00
groups.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
knowledge.py refac 2026-06-29 01:41:43 -05:00
memories.py refac 2026-06-29 00:26:35 -05:00
messages.py perf(channels): batch N+1 queries for reactions and thread replies (#25831) 2026-06-29 02:05:16 -05:00
models.py chore: format 2026-06-01 13:56:55 -07:00
notes.py refac 2026-05-14 01:49:34 +09:00
oauth_sessions.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
prompt_history.py fix: bind prompt history/version ops to the authorized prompt (#25056) 2026-06-01 12:07:52 -07:00
prompts.py chore: format 2026-06-01 13:56:55 -07:00
shared_chats.py feat(ui): add 'Unshare All Shared Chats' button to Shared Chats modal (#25848) 2026-06-17 03:06:41 +02:00
skills.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tags.py chore: format 2026-06-01 13:56:55 -07:00
tools.py solve-valves-icon-disappear-issue (#26256) 2026-06-29 00:56:44 -05:00
users.py chore: format 2026-06-01 13:56:55 -07:00