add indexes so counting topics and posts is faster

This commit is contained in:
Sam 2013-03-19 18:30:02 -07:00
parent fcbc77d0cd
commit 204759a3ea

View File

@ -0,0 +1,14 @@
class AddUserIndexesToPostsAndTopics < ActiveRecord::Migration
def up
execute "CREATE INDEX idx_posts_user_id_deleted_at
ON posts(user_id) WHERE deleted_at IS NULL"
execute "CREATE INDEX idx_topics_user_id_deleted_at
ON topics(user_id) WHERE deleted_at IS NULL"
end
def down
execute "DROP INDEX idx_posts_user_id_deleted_at"
execute "DROP INDEX idx_topics_user_id_deleted_at"
end
end