Commit 6c81504a authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'sh-add-index-for-deployments' into 'master'

Add indexes on deployments to improve environments search

Closes #55353

See merge request gitlab-org/gitlab!21789
parents 965ba87d 92d3c08f
---
title: Add indexes on deployments to improve environments search
merge_request: 21789
author:
type: performance
# frozen_string_literal: true
class AddIndexesToDeploymentsOnProjectIdAndRef < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'partial_index_deployments_for_project_id_and_tag'.freeze
disable_ddl_transaction!
def up
add_concurrent_index :deployments, [:project_id, :ref]
add_concurrent_index :deployments, [:project_id], where: 'tag IS TRUE', name: INDEX_NAME
end
def down
remove_concurrent_index :deployments, [:project_id, :ref]
remove_concurrent_index :deployments, [:project_id], where: 'tag IS TRUE', name: INDEX_NAME
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_12_08_071112) do
ActiveRecord::Schema.define(version: 2019_12_14_175727) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
......@@ -1357,9 +1357,11 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) do
t.index ["id"], name: "partial_index_deployments_for_legacy_successful_deployments", where: "((finished_at IS NULL) AND (status = 2))"
t.index ["project_id", "id"], name: "index_deployments_on_project_id_and_id", order: { id: :desc }
t.index ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true
t.index ["project_id", "ref"], name: "index_deployments_on_project_id_and_ref"
t.index ["project_id", "status", "created_at"], name: "index_deployments_on_project_id_and_status_and_created_at"
t.index ["project_id", "status"], name: "index_deployments_on_project_id_and_status"
t.index ["project_id", "updated_at", "id"], name: "index_deployments_on_project_id_and_updated_at_and_id", order: { updated_at: :desc, id: :desc }
t.index ["project_id"], name: "partial_index_deployments_for_project_id_and_tag", where: "(tag IS TRUE)"
end
create_table "description_versions", force: :cascade do |t|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment