diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-12 00:12:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-12 00:12:17 +0300 |
commit | f8dfaa8d4140328fa63282d3d6ac159d571dab84 (patch) | |
tree | 9f4653f3789362f95974bfe3ca88bd10fde59b00 /db | |
parent | e57809ded8e4e64c0528d33a5f59e9160e310d14 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20220209111007_add_partial_index_for_batching_active_cluster_image_scanning_vulnerabilities.rb | 16 | ||||
-rw-r--r-- | db/schema_migrations/20220209111007 | 1 | ||||
-rw-r--r-- | db/structure.sql | 2 |
3 files changed, 19 insertions, 0 deletions
diff --git a/db/post_migrate/20220209111007_add_partial_index_for_batching_active_cluster_image_scanning_vulnerabilities.rb b/db/post_migrate/20220209111007_add_partial_index_for_batching_active_cluster_image_scanning_vulnerabilities.rb new file mode 100644 index 00000000000..d38509ed8c2 --- /dev/null +++ b/db/post_migrate/20220209111007_add_partial_index_for_batching_active_cluster_image_scanning_vulnerabilities.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddPartialIndexForBatchingActiveClusterImageScanningVulnerabilities < Gitlab::Database::Migration[1.0] + INDEX_NAME = 'index_vulnerabilities_on_project_id_and_id_active_cis' + INDEX_FILTER_CONDITION = 'report_type = 7 AND state = ANY(ARRAY[1, 4])' + + disable_ddl_transaction! + + def up + add_concurrent_index :vulnerabilities, [:project_id, :id], where: INDEX_FILTER_CONDITION, name: INDEX_NAME + end + + def down + remove_concurrent_index :vulnerabilities, [:project_id, :id], name: INDEX_NAME + end +end diff --git a/db/schema_migrations/20220209111007 b/db/schema_migrations/20220209111007 new file mode 100644 index 00000000000..f10e05b8918 --- /dev/null +++ b/db/schema_migrations/20220209111007 @@ -0,0 +1 @@ +9462258bcbe45ab80f7ef5a02f8b8d5c0ed6ac69bf04b8934ae3dee2261ba458
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 501f304a706..6bdf5ccb6fc 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -28144,6 +28144,8 @@ CREATE INDEX index_vulnerabilities_on_milestone_id ON vulnerabilities USING btre CREATE INDEX index_vulnerabilities_on_project_id_and_id ON vulnerabilities USING btree (project_id, id); +CREATE INDEX index_vulnerabilities_on_project_id_and_id_active_cis ON vulnerabilities USING btree (project_id, id) WHERE ((report_type = 7) AND (state = ANY (ARRAY[1, 4]))); + CREATE INDEX index_vulnerabilities_on_project_id_and_state_and_severity ON vulnerabilities USING btree (project_id, state, severity); CREATE INDEX index_vulnerabilities_on_resolved_by_id ON vulnerabilities USING btree (resolved_by_id); |