Skip to content

A platform for community discussion. Free, open, simple.

PERF: Add user_id condition so we can use another index in the query

Rafael dos Santos Silvaa4d5d1f51d84
diff --git a/app/models/user_summary.rb b/app/models/user_summary.rb
index 09c025bc91d..a62e7d1d850 100644
--- a/app/models/user_summary.rb
+++ b/app/models/user_summary.rb
@@ -39,6 +39,7 @@ class UserSummary
def links
TopicLink
.joins(:topic, :post)
+ .where(posts: { user_id: @user.id })
.includes(:topic, :post)
.where('posts.post_type IN (?)', Topic.visible_post_types(@guardian && @guardian.user))
.merge(Topic.listable_topics.visible.secured(@guardian))