Commit acec65a5 authored by Furkan Ayhan's avatar Furkan Ayhan

Add project_id, user_id, status, ref index to ci_pipelines

After adding username filter to pipelines, we realized this missing
index.

We exclude source=12 because we don't display child pipelines in index
parent 7036dca0
---
title: Add project_id, user_id, status, ref index to ci_pipelines
merge_request: 33290
author:
type: performance
# frozen_string_literal: true
class AddProjectIdUserIdStatusRefIndexToCiPipelines < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
SOURCE_PARENT_PIPELINE = 12
def up
add_concurrent_index(
:ci_pipelines,
[:project_id, :user_id, :status, :ref],
where: "source != #{SOURCE_PARENT_PIPELINE}"
)
end
def down
remove_concurrent_index(
:ci_pipelines,
[:project_id, :user_id, :status, :ref],
where: "source != #{SOURCE_PARENT_PIPELINE}"
)
end
end
......@@ -9408,6 +9408,8 @@ CREATE INDEX index_ci_pipelines_on_project_id_and_status_and_config_source ON pu
CREATE INDEX index_ci_pipelines_on_project_id_and_status_and_updated_at ON public.ci_pipelines USING btree (project_id, status, updated_at);
CREATE INDEX index_ci_pipelines_on_project_id_and_user_id_and_status_and_ref ON public.ci_pipelines USING btree (project_id, user_id, status, ref) WHERE (source <> 12);
CREATE INDEX index_ci_pipelines_on_project_idandrefandiddesc ON public.ci_pipelines USING btree (project_id, ref, id DESC);
CREATE INDEX index_ci_pipelines_on_status ON public.ci_pipelines USING btree (status);
......@@ -13776,6 +13778,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200527152116
20200527152657
20200528123703
20200528125905
20200603073101
\.
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