mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-15 23:32:40 +00:00
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 |
||
|---|---|---|
| .. | ||
| access_grants.py | ||
| auths.py | ||
| automations.py | ||
| calendar.py | ||
| channels.py | ||
| chat_messages.py | ||
| chats.py | ||
| config.py | ||
| feedbacks.py | ||
| files.py | ||
| folders.py | ||
| functions.py | ||
| groups.py | ||
| knowledge.py | ||
| memories.py | ||
| messages.py | ||
| models.py | ||
| notes.py | ||
| oauth_sessions.py | ||
| prompt_history.py | ||
| prompts.py | ||
| shared_chats.py | ||
| skills.py | ||
| tags.py | ||
| tools.py | ||
| users.py | ||