From af75360942a4c29fee7babd2bc828a579ec11bcb Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 Sep 2014 23:03:59 +1000 Subject: [PATCH] PERF: reverse index on topic users to speed up join --- db/migrate/20140910130155_create_topic_user_index.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/migrate/20140910130155_create_topic_user_index.rb diff --git a/db/migrate/20140910130155_create_topic_user_index.rb b/db/migrate/20140910130155_create_topic_user_index.rb new file mode 100644 index 00000000000..0f02e645348 --- /dev/null +++ b/db/migrate/20140910130155_create_topic_user_index.rb @@ -0,0 +1,6 @@ +class CreateTopicUserIndex < ActiveRecord::Migration + def change + # seems to be the most effective for joining into topics + add_index :topic_users, [:user_id, :topic_id], unique: true + end +end