From 87b8b900bb17d293c5d9c35b3f62890d42734514 Mon Sep 17 00:00:00 2001 From: Maxime Orefice <morefice@gitlab.com> Date: Wed, 18 May 2022 11:25:07 +0200 Subject: [PATCH] Prepare async index to for Ci::JobArtifact This commit adds a new index to optimize how we fetch job artifacts when recalculating artifact size and ordering them by id. Changelog: performance --- ...518091952_prepare_job_artifact_ordering_index.rb | 13 +++++++++++++ db/schema_migrations/20220518091952 | 1 + 2 files changed, 14 insertions(+) create mode 100644 db/post_migrate/20220518091952_prepare_job_artifact_ordering_index.rb create mode 100644 db/schema_migrations/20220518091952 diff --git a/db/post_migrate/20220518091952_prepare_job_artifact_ordering_index.rb b/db/post_migrate/20220518091952_prepare_job_artifact_ordering_index.rb new file mode 100644 index 000000000000..df44ffb05256 --- /dev/null +++ b/db/post_migrate/20220518091952_prepare_job_artifact_ordering_index.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class PrepareJobArtifactOrderingIndex < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_ci_job_artifacts_on_id_and_created_at_and_project_id' + + def up + prepare_async_index :ci_job_artifacts, [:id, :created_at, :project_id], name: INDEX_NAME + end + + def down + unprepare_async_index :notes, [:id, :created_at, :project_id], name: INDEX_NAME + end +end diff --git a/db/schema_migrations/20220518091952 b/db/schema_migrations/20220518091952 new file mode 100644 index 000000000000..3cd6a29f1cfc --- /dev/null +++ b/db/schema_migrations/20220518091952 @@ -0,0 +1 @@ +d8862fbc28d41c2d61dbb49415ab344e5c010940cede13fe2c6bfdc7832fb605 \ No newline at end of file -- GitLab