From 91c971bf987824df0e066c20ac341bb5e7485e95 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 4 May 2017 20:43:46 +0200 Subject: Index project_group_links.group_id This column is used when refreshing authorizations and without the index leads to a sequence scan being performed on this table. --- ...04182103_add_index_project_group_links_group_id.rb | 19 +++++++++++++++++++ db/schema.rb | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 db/migrate/20170504182103_add_index_project_group_links_group_id.rb diff --git a/db/migrate/20170504182103_add_index_project_group_links_group_id.rb b/db/migrate/20170504182103_add_index_project_group_links_group_id.rb new file mode 100644 index 00000000000..62bf641daa6 --- /dev/null +++ b/db/migrate/20170504182103_add_index_project_group_links_group_id.rb @@ -0,0 +1,19 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexProjectGroupLinksGroupId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :project_group_links, :group_id + end + + def down + remove_concurrent_index :project_group_links, :group_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 9773203e9cd..2567dda0edc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -925,6 +925,8 @@ ActiveRecord::Schema.define(version: 20170508190732) do t.date "expires_at" end + add_index "project_group_links", ["group_id"], name: "index_project_group_links_on_group_id", using: :btree + create_table "project_import_data", force: :cascade do |t| t.integer "project_id" t.text "data" -- cgit v1.2.1