From 085493e35d41a2c2c846f6d15f8d5339cac7f992 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 19 Sep 2013 18:34:42 -0700 Subject: [PATCH] optimise regular job to avoid touching posts that have not changed --- app/models/post.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index eca7cee99..fd892902f 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -284,7 +284,8 @@ class Post < ActiveRecord::Base AND p2.user_id <> post_timings.user_id GROUP BY post_timings.topic_id, post_timings.post_number) AS x WHERE x.topic_id = posts.topic_id - AND x.post_number = posts.post_number") + AND x.post_number = posts.post_number + AND (posts.avg_time <> (x.gmean / 1000)::int OR posts.avg_time IS NULL)") end end