PERF: Add index_topic_id_percent_rank_on_posts.

Speeds up the `Posts#summary` mode query for large topics.
This commit is contained in:
Guo Xiang Tan 2018-06-21 09:44:49 +08:00
parent 2d59d06916
commit c1972f8438

View File

@ -0,0 +1,9 @@
class AddIndexTopicIdPercentRankOnPosts < ActiveRecord::Migration[5.2]
def up
add_index :posts, [:topic_id, :percent_rank], order: { percent_rank: :asc }
end
def down
remove_index :posts, [:topic_id, :percent_rank]
end
end