From b4e1388f9bebc458a63cfd4864864ad9df7b7b0a Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 10 Jul 2018 16:23:53 +0800 Subject: [PATCH] PERF: Drop support for gaps in mega topics. Based on our current implementation, there isn't a practical way to determine the gaps of large topics cheaply. We tried to load the gaps in chunks but felt that the code becomes too complicated. Note that megatopics are quite rare in the wild. --- lib/topic_view.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/topic_view.rb b/lib/topic_view.rb index b08eba259f..26c4b6a96a 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -104,7 +104,14 @@ class TopicView def gaps return unless @contains_gaps - @gaps ||= Gaps.new(filtered_post_ids, unfiltered_posts.order(:sort_order).pluck(:id)) + + @gaps ||= begin + if is_mega_topic? + nil + else + Gaps.new(filtered_post_ids, unfiltered_posts.order(:sort_order).pluck(:id)) + end + end end def last_post