2
0
Fork 0
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:
Guo Xiang Tan 2016-06-28 10:01:00 +08:00
parent b4cb2e367c
commit e221414935
No known key found for this signature in database
GPG key ID: 19C321C8952B0F72
5 changed files with 9 additions and 5 deletions

View file

@ -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