diff options
author | Stan Hu <stanhu@gmail.com> | 2019-08-29 01:52:53 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-08-29 01:52:53 +0000 |
commit | 87aa5e7ad25bf576dfdb87ddc783c9f23099b6e7 (patch) | |
tree | fd07f390269a38ad420f376c02308f573399d7a9 | |
parent | b34120336d33e57d9817559f82771f8da4f5f2b3 (diff) | |
parent | 3ed555f3c980ef7c21efd17cabc06a8037643787 (diff) | |
download | gitlab-ce-87aa5e7ad25bf576dfdb87ddc783c9f23099b6e7.tar.gz |
Merge branch 'cluster_deployments' into 'master'
Add index to improve query performance
See merge request gitlab-org/gitlab-ce!31988
-rw-r--r-- | changelogs/unreleased/cluster_deployments.yml | 5 | ||||
-rw-r--r-- | db/migrate/20190819131155_add_cluster_status_index_to_deployments.rb | 17 | ||||
-rw-r--r-- | db/migrate/20190826090628_remove_redundant_deployments_index.rb | 18 | ||||
-rw-r--r-- | db/schema.rb | 2 |
4 files changed, 41 insertions, 1 deletions
diff --git a/changelogs/unreleased/cluster_deployments.yml b/changelogs/unreleased/cluster_deployments.yml new file mode 100644 index 00000000000..d854d16ea72 --- /dev/null +++ b/changelogs/unreleased/cluster_deployments.yml @@ -0,0 +1,5 @@ +--- +title: Add index to improve group cluster deployments query performance +merge_request: 31988 +author: +type: other diff --git a/db/migrate/20190819131155_add_cluster_status_index_to_deployments.rb b/db/migrate/20190819131155_add_cluster_status_index_to_deployments.rb new file mode 100644 index 00000000000..bfa91e33558 --- /dev/null +++ b/db/migrate/20190819131155_add_cluster_status_index_to_deployments.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddClusterStatusIndexToDeployments < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :deployments, [:cluster_id, :status] + end + + def down + remove_concurrent_index :deployments, [:cluster_id, :status] + end +end diff --git a/db/migrate/20190826090628_remove_redundant_deployments_index.rb b/db/migrate/20190826090628_remove_redundant_deployments_index.rb new file mode 100644 index 00000000000..6b009c17d64 --- /dev/null +++ b/db/migrate/20190826090628_remove_redundant_deployments_index.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class RemoveRedundantDeploymentsIndex < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_concurrent_index :deployments, :cluster_id + end + + def down + add_concurrent_index :deployments, :cluster_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 454ea939a6f..54774b0a65b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1146,7 +1146,7 @@ ActiveRecord::Schema.define(version: 2019_08_28_083843) do t.integer "status", limit: 2, null: false t.datetime_with_timezone "finished_at" t.integer "cluster_id" - t.index ["cluster_id"], name: "index_deployments_on_cluster_id" + t.index ["cluster_id", "status"], name: "index_deployments_on_cluster_id_and_status" t.index ["created_at"], name: "index_deployments_on_created_at" t.index ["deployable_type", "deployable_id"], name: "index_deployments_on_deployable_type_and_deployable_id" t.index ["environment_id", "id"], name: "index_deployments_on_environment_id_and_id" |