Commit 25dc65cc authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '325503-fix-update-all-mirrors-db-performance' into 'master'

Add partial index to improve mirrors update

See merge request gitlab-org/gitlab!57353
parents 147c2e9b a4eff9c1
---
title: Add partial index to improve mirrors update
merge_request: 57353
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 AddIndexMirrorDataOnRetryNextExecutionWhereStatus < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_mirror_data_non_scheduled_or_started'
disable_ddl_transaction!
def up
add_concurrent_index :project_mirror_data,
[:next_execution_timestamp, :retry_count],
where: "(status)::text <> ALL ('{scheduled,started}'::text[])",
name: INDEX_NAME
end
def down
remove_concurrent_index :project_mirror_data,
[:next_execution_timestamp, :retry_count],
where: "(status)::text <> ALL ('{scheduled,started}'::text[])",
name: INDEX_NAME
end
end
7e6dd4e247ad6b610ebebcf59b4212fd0d2258c8fff008d525b891da872613e5
\ No newline at end of file
...@@ -23082,6 +23082,8 @@ CREATE INDEX index_milestones_on_title ON milestones USING btree (title); ...@@ -23082,6 +23082,8 @@ CREATE INDEX index_milestones_on_title ON milestones USING btree (title);
CREATE INDEX index_milestones_on_title_trigram ON milestones USING gin (title gin_trgm_ops); CREATE INDEX index_milestones_on_title_trigram ON milestones USING gin (title gin_trgm_ops);
CREATE INDEX index_mirror_data_non_scheduled_or_started ON project_mirror_data USING btree (next_execution_timestamp, retry_count) WHERE ((status)::text <> ALL ('{scheduled,started}'::text[]));
CREATE INDEX index_mirror_data_on_next_execution_and_retry_count ON project_mirror_data USING btree (next_execution_timestamp, retry_count); CREATE INDEX index_mirror_data_on_next_execution_and_retry_count ON project_mirror_data USING btree (next_execution_timestamp, retry_count);
CREATE UNIQUE INDEX index_mr_blocks_on_blocking_and_blocked_mr_ids ON merge_request_blocks USING btree (blocking_merge_request_id, blocked_merge_request_id); CREATE UNIQUE INDEX index_mr_blocks_on_blocking_and_blocked_mr_ids ON merge_request_blocks USING btree (blocking_merge_request_id, blocked_merge_request_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