add indexes so counting topics and posts is faster
This commit is contained in:
parent
fcbc77d0cd
commit
204759a3ea
|
@ -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
|
Loading…
Reference in New Issue