From 5f94c29adab94c1f101b3961f5c52637d5c98ed5 Mon Sep 17 00:00:00 2001 From: Neil Lalonde <neillalonde@gmail.com> Date: Tue, 17 Jun 2014 17:01:13 -0400 Subject: [PATCH] Add index on topic_links post_id. Remove a redundant index. --- ...7193351_add_and_remove_indexes_on_topic_links.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20140617193351_add_and_remove_indexes_on_topic_links.rb diff --git a/db/migrate/20140617193351_add_and_remove_indexes_on_topic_links.rb b/db/migrate/20140617193351_add_and_remove_indexes_on_topic_links.rb new file mode 100644 index 000000000..1ddbf6e8f --- /dev/null +++ b/db/migrate/20140617193351_add_and_remove_indexes_on_topic_links.rb @@ -0,0 +1,13 @@ +class AddAndRemoveIndexesOnTopicLinks < ActiveRecord::Migration + def up + # Index (topic_id) is a subset of (topic_id, post_id, url) + remove_index :topic_links, :topic_id + + add_index :topic_links, :post_id + end + + def down + remove_index :topic_links, :post_id + add_index :topic_links, :topic_id + end +end