A platform for community discussion. Free, open, simple.
PERF: Improve performance of queries when loading a topic list (#22949)
Alan Guo Xiang Tan135e88cb12ed
diff --git a/lib/topic_query.rb b/lib/topic_query.rbindex 3409f754586..4db4b8d090b 100644--- a/lib/topic_query.rb+++ b/lib/topic_query.rb@@ -750,7 +750,9 @@ class TopicQueryendif SiteSetting.tagging_enabled- result = result.includes(:tags)+ # Use `preload` here instead since `includes` can end up calling `eager_load` which can unnecessarily lead to+ # joins on the `topic_tags` and `tags` table leading to a much slower query.+ result = result.preload(:tags)result = filter_by_tags(result)end