PERF: hit all index conditions to speed up anon ip tracking

This commit is contained in:
Sam 2015-05-14 17:21:02 +10:00
parent 2b2d0e803f
commit 4a48f983fd
2 changed files with 2 additions and 1 deletions

View file

@ -33,7 +33,7 @@ class TopicViewItem < ActiveRecord::Base
builder = SqlBuilder.new(sql)
if !user_id
builder.where("ip_address = :ip_address AND topic_id = :topic_id")
builder.where("ip_address = :ip_address AND topic_id = :topic_id AND user_id IS NULL")
else
builder.where("user_id = :user_id AND topic_id = :topic_id")
end

View file

@ -124,6 +124,7 @@ class TopicViewSerializer < ApplicationSerializer
def include_is_warning?
is_warning
end
def draft
object.draft
end