Commit bd223c55 authored by Robert May's avatar Robert May

Update MR index to include id

Updates an index used in the merge requests API endpoints
to cover all the fields being used in the query. This has
a notable performance benefit.
parent 0e109c7e
---
title: Update MR index to include id
merge_request: 42222
author:
type: performance
# frozen_string_literal: true
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class ModifyMergeRequestApiIndex < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :merge_requests, [:target_project_id, :created_at, :id]
end
def down
remove_concurrent_index :merge_requests, [:target_project_id, :created_at, :id]
end
end
# frozen_string_literal: true
class RemoveOldMergeRequestApiIndex < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index :merge_requests, [:target_project_id, :created_at]
end
def down
add_concurrent_index :merge_requests, [:target_project_id, :created_at]
end
end
49b492717acca6d43e16caafda0b75f6e1a3630592149b04d1148758406ae1a7
\ No newline at end of file
6cd644220e07f477a87ddc8bb8b2de3ed920c0c76383122bab95c939e21abbb2
\ No newline at end of file
...@@ -20326,6 +20326,8 @@ CREATE INDEX index_merge_requests_on_sprint_id ON public.merge_requests USING bt ...@@ -20326,6 +20326,8 @@ CREATE INDEX index_merge_requests_on_sprint_id ON public.merge_requests USING bt
CREATE INDEX index_merge_requests_on_target_branch ON public.merge_requests USING btree (target_branch); CREATE INDEX index_merge_requests_on_target_branch ON public.merge_requests USING btree (target_branch);
CREATE INDEX index_merge_requests_on_target_project_id_and_created_at_and_id ON public.merge_requests USING btree (target_project_id, created_at, id);
CREATE UNIQUE INDEX index_merge_requests_on_target_project_id_and_iid ON public.merge_requests USING btree (target_project_id, iid); CREATE UNIQUE INDEX index_merge_requests_on_target_project_id_and_iid ON public.merge_requests USING btree (target_project_id, iid);
CREATE INDEX index_merge_requests_on_target_project_id_and_target_branch ON public.merge_requests USING btree (target_project_id, target_branch) WHERE ((state_id = 1) AND (merge_when_pipeline_succeeds = true)); CREATE INDEX index_merge_requests_on_target_project_id_and_target_branch ON public.merge_requests USING btree (target_project_id, target_branch) WHERE ((state_id = 1) AND (merge_when_pipeline_succeeds = true));
...@@ -20338,8 +20340,6 @@ CREATE INDEX index_merge_requests_on_tp_id_and_merge_commit_sha_and_id ON public ...@@ -20338,8 +20340,6 @@ CREATE INDEX index_merge_requests_on_tp_id_and_merge_commit_sha_and_id ON public
CREATE INDEX index_merge_requests_on_updated_by_id ON public.merge_requests USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL); CREATE INDEX index_merge_requests_on_updated_by_id ON public.merge_requests USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL);
CREATE INDEX index_merge_requests_target_project_id_created_at ON public.merge_requests USING btree (target_project_id, created_at);
CREATE UNIQUE INDEX index_merge_trains_on_merge_request_id ON public.merge_trains USING btree (merge_request_id); CREATE UNIQUE INDEX index_merge_trains_on_merge_request_id ON public.merge_trains USING btree (merge_request_id);
CREATE INDEX index_merge_trains_on_pipeline_id ON public.merge_trains USING btree (pipeline_id); CREATE INDEX index_merge_trains_on_pipeline_id ON public.merge_trains USING btree (pipeline_id);
......
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