From 237968b1b7239f9be2fc0c2d2fea6eb572c302f6 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 24 Aug 2017 13:33:25 -0400 Subject: [PATCH] PERF: add an index on slug to make sure that slug lookups are quick --- db/migrate/20170824172615_add_slug_index_on_topic.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20170824172615_add_slug_index_on_topic.rb diff --git a/db/migrate/20170824172615_add_slug_index_on_topic.rb b/db/migrate/20170824172615_add_slug_index_on_topic.rb new file mode 100644 index 00000000000..eceb567fc96 --- /dev/null +++ b/db/migrate/20170824172615_add_slug_index_on_topic.rb @@ -0,0 +1,9 @@ +class AddSlugIndexOnTopic < ActiveRecord::Migration + def up + execute 'CREATE INDEX idxTopicSlug ON topics(slug) WHERE deleted_at IS NULL AND slug IS NOT NULL' + end + + def down + execute 'DROP INDEX idxTopicSlug' + end +end