PERF: Faster TL3 promotion replies needed calculation (#10416)

Removing the LIMIT makes PostgreSQL use index_posts_on_user_id_and_created_at
which is much faster overall.

Before: 22 seconds
After: 100 ms
This commit is contained in:
Rafael dos Santos Silva
2020-08-12 11:28:34 -03:00
committed by GitHub
parent 00a0767c35
commit 28669dfeb2
3 changed files with 6 additions and 10 deletions

View File

@@ -91,7 +91,7 @@ class Promotion
return false if stat.days_visited < SiteSetting.tl2_requires_days_visited
return false if stat.likes_received < SiteSetting.tl2_requires_likes_received
return false if stat.likes_given < SiteSetting.tl2_requires_likes_given
return false if stat.calc_topic_reply_count!(SiteSetting.tl2_requires_topic_reply_count) < SiteSetting.tl2_requires_topic_reply_count
return false if stat.calc_topic_reply_count! < SiteSetting.tl2_requires_topic_reply_count
true
end