Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-04-19 06:00:35 +0300
committerStan Hu <stanhu@gmail.com>2017-04-19 16:45:01 +0300
commit3f0054a88c84ef5631ee82c1cc9bc985c2eea58b (patch)
tree0464eb8ec25de8420f23d3669c66ddfdeb3260e1 /db/migrate/20170419001229_add_index_to_system_note_metadata.rb
parenta9da37434af6d44c5f851affd4bd69b370760e8e (diff)
Add unique index for note_id to system note metadata table
In issue 1, the sequential scan was taking 250+ ms.
Diffstat (limited to 'db/migrate/20170419001229_add_index_to_system_note_metadata.rb')
-rw-r--r--db/migrate/20170419001229_add_index_to_system_note_metadata.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20170419001229_add_index_to_system_note_metadata.rb b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb
new file mode 100644
index 00000000000..c68fd920fff
--- /dev/null
+++ b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb
@@ -0,0 +1,17 @@
+class AddIndexToSystemNoteMetadata < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # MySQL automatically creates an index on a foreign-key constraint; PostgreSQL does not
+ add_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql?
+ end
+
+ def down
+ remove_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql?
+ end
+end