mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
PERF: Remove N+1 queries on user messages page.
This commit is contained in:
parent
b4cb2e367c
commit
e221414935
5 changed files with 9 additions and 5 deletions
|
@ -355,10 +355,10 @@ class TopicQuery
|
|||
options = @options
|
||||
options.reverse_merge!(per_page: per_page_setting)
|
||||
|
||||
result = Topic
|
||||
result = Topic.includes(:tags)
|
||||
|
||||
if type == :group
|
||||
result = result.includes(:allowed_groups)
|
||||
result = result.includes(:allowed_users)
|
||||
result = result.where("topics.id IN (SELECT topic_id FROM topic_allowed_groups
|
||||
WHERE group_id IN (
|
||||
SELECT group_id FROM group_users WHERE user_id = #{user.id.to_i}) AND
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue