Commit 7b72698a authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'optimize-query-for-last-deployment' into 'master'

Optimize database query for last deployment

See merge request gitlab-org/gitlab!57979
parents 0a7d75aa 275ceeee
---
title: Optimize database query for last deployment
merge_request: 57979
author:
type: performance
# frozen_string_literal: true
class AddIndexForLastDeployment < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_deployments_on_environment_id_status_and_id'
disable_ddl_transaction!
def up
add_concurrent_index :deployments, [:environment_id, :status, :id], name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :deployments, INDEX_NAME
end
end
f27446d1950acaf45f623b2cec7733cd7ba4b82eefddfa2203acbbaf77d59e18
\ No newline at end of file
......@@ -22520,6 +22520,8 @@ CREATE INDEX index_deployments_on_environment_id_and_iid_and_project_id ON deplo
CREATE INDEX index_deployments_on_environment_id_status_and_finished_at ON deployments USING btree (environment_id, status, finished_at);
CREATE INDEX index_deployments_on_environment_id_status_and_id ON deployments USING btree (environment_id, status, id);
CREATE INDEX index_deployments_on_environment_status_sha ON deployments USING btree (environment_id, status, sha);
CREATE INDEX index_deployments_on_id_and_status_and_created_at ON deployments USING btree (id, status, created_at);
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