Commit 3cd615b6 authored by Patrick Bair's avatar Patrick Bair

Merge branch 'ak/add-index-on-builds' into 'master'

Improve ci_builds runner_id index

See merge request gitlab-org/gitlab!48241
parents 5c7db792 d016696d
---
title: Adds id desc to index_ci_builds_on_runner_id_and_id_desc
merge_request: 48241
author:
type: fixed
# frozen_string_literal: true
class AddRunnerIdAndIdDescIndexToCiBuilds < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
NEW_INDEX = 'index_ci_builds_on_runner_id_and_id_desc'
OLD_INDEX = 'index_ci_builds_on_runner_id'
disable_ddl_transaction!
def up
add_concurrent_index :ci_builds, %i[runner_id id], name: NEW_INDEX, order: { id: :desc }
remove_concurrent_index_by_name :ci_builds, OLD_INDEX
end
def down
add_concurrent_index :ci_builds, %i[runner_id], name: OLD_INDEX
remove_concurrent_index_by_name :ci_builds, NEW_INDEX
end
end
6b88d79aa8d373fa1d9aa2698a9d20c09aff14ef16af4c123abd4e7c98e41311
\ No newline at end of file
...@@ -20482,7 +20482,7 @@ CREATE INDEX index_ci_builds_on_protected ON ci_builds USING btree (protected); ...@@ -20482,7 +20482,7 @@ CREATE INDEX index_ci_builds_on_protected ON ci_builds USING btree (protected);
CREATE INDEX index_ci_builds_on_queued_at ON ci_builds USING btree (queued_at); CREATE INDEX index_ci_builds_on_queued_at ON ci_builds USING btree (queued_at);
CREATE INDEX index_ci_builds_on_runner_id ON ci_builds USING btree (runner_id); CREATE INDEX index_ci_builds_on_runner_id_and_id_desc ON ci_builds USING btree (runner_id, id DESC);
CREATE INDEX index_ci_builds_on_stage_id ON ci_builds USING btree (stage_id); CREATE INDEX index_ci_builds_on_stage_id ON ci_builds USING btree (stage_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