diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-06-26 16:00:02 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-06-26 16:00:09 +0300 |
commit | 05a6a71aef5f9aca56508df054c5ea35a748f30c (patch) | |
tree | 2a6691f8bc2217d73fc06795c4ece1d95eb2cdd1 | |
parent | 7da7af3a22058a6fb4e22cbf2b659e910cc92d54 (diff) |
Add index on deployable_type/id for deployments
-rw-r--r-- | changelogs/unreleased/add-missing-index-for-deployments.yml | 5 | ||||
-rw-r--r-- | db/migrate/20180626125654_add_index_on_deployable_for_deployments.rb | 18 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/changelogs/unreleased/add-missing-index-for-deployments.yml b/changelogs/unreleased/add-missing-index-for-deployments.yml new file mode 100644 index 00000000000..7863c0ee039 --- /dev/null +++ b/changelogs/unreleased/add-missing-index-for-deployments.yml @@ -0,0 +1,5 @@ +--- +title: Add index on deployable_type/id for deployments +merge_request: +author: +type: performance diff --git a/db/migrate/20180626125654_add_index_on_deployable_for_deployments.rb b/db/migrate/20180626125654_add_index_on_deployable_for_deployments.rb new file mode 100644 index 00000000000..a0e3a228f6c --- /dev/null +++ b/db/migrate/20180626125654_add_index_on_deployable_for_deployments.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexOnDeployableForDeployments < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :deployments, [:deployable_type, :deployable_id] + end + + def down + remove_concurrent_index :deployments, [:deployable_type, :deployable_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index d05c6afbb9f..0112fc726d4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180608201435) do +ActiveRecord::Schema.define(version: 20180626125654) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -757,6 +757,7 @@ ActiveRecord::Schema.define(version: 20180608201435) do end add_index "deployments", ["created_at"], name: "index_deployments_on_created_at", using: :btree + add_index "deployments", ["deployable_type", "deployable_id"], name: "index_deployments_on_deployable_type_and_deployable_id", using: :btree add_index "deployments", ["environment_id", "id"], name: "index_deployments_on_environment_id_and_id", using: :btree add_index "deployments", ["environment_id", "iid", "project_id"], name: "index_deployments_on_environment_id_and_iid_and_project_id", using: :btree add_index "deployments", ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true, using: :btree |