diff --git a/changelogs/unreleased/create-index-for-cs.yml b/changelogs/unreleased/create-index-for-cs.yml new file mode 100644 index 0000000000000000000000000000000000000000..05a78c36e35ff57a920761502609f83b51f4348e --- /dev/null +++ b/changelogs/unreleased/create-index-for-cs.yml @@ -0,0 +1,5 @@ +--- +title: Add temporary index for container scanning findings +merge_request: 39962 +author: +type: other diff --git a/db/migrate/20200820105408_add_index_to_container_scanning_findings.rb b/db/migrate/20200820105408_add_index_to_container_scanning_findings.rb new file mode 100644 index 0000000000000000000000000000000000000000..834e11e3d6e51511222b535952491d5e734a74ee --- /dev/null +++ b/db/migrate/20200820105408_add_index_to_container_scanning_findings.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddIndexToContainerScanningFindings < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'idx_container_scanning_findings' + + disable_ddl_transaction! + + def up + add_concurrent_index(:vulnerability_occurrences, :id, + where: "report_type = 2", + name: INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(:project_registry, INDEX_NAME) + end +end diff --git a/db/schema_migrations/20200820105408 b/db/schema_migrations/20200820105408 new file mode 100644 index 0000000000000000000000000000000000000000..647a86797dd09a13e87176938d4912b2bde23b41 --- /dev/null +++ b/db/schema_migrations/20200820105408 @@ -0,0 +1 @@ +e21ae06853e3a071669fa8e9ed2638f0e7854813bc5a1639b31ad6edb50f6427 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index ba020532953ec9a8f92727a00f2ab1bd78b5cdea..bec2f11356c5602f1ee35a7cac5b34967241662a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -18909,6 +18909,8 @@ CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_index ON public.epic_user_ment CREATE INDEX idx_ci_pipelines_artifacts_locked ON public.ci_pipelines USING btree (ci_ref_id, id) WHERE (locked = 1); +CREATE INDEX idx_container_scanning_findings ON public.vulnerability_occurrences USING btree (id) WHERE (report_type = 2); + CREATE INDEX idx_deployment_clusters_on_cluster_id_and_kubernetes_namespace ON public.deployment_clusters USING btree (cluster_id, kubernetes_namespace); CREATE UNIQUE INDEX idx_deployment_merge_requests_unique_index ON public.deployment_merge_requests USING btree (deployment_id, merge_request_id);