Skip to content

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

PERF: avoids eager pluck in posts controller (#21973)

Joffrey JAFFEUX821e9cb649f2
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 078b0efc9e0..42a819c3785 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -783,7 +783,7 @@ class PostsController < ApplicationController
topics = Topic.where(id: topic_ids).with_deleted.where.not(archetype: "private_message")
topics = topics.secured(guardian)
- posts = posts.where(topic_id: topics.pluck(:id))
+ posts = posts.where(topic_id: topics)
end
posts.offset(opts[:offset]).limit(opts[:limit])