Commit 3b6bc848 authored by Sashi's avatar Sashi

Add index for cluster_id in vulnerability_occurrences location

This change adds GIN index on location->cluster_id
in vulnerability_occurrences table. location is a jsonb column
and cluster_id field will only be present for
cluster_image_scanning report_type.

Changelog: performance
parent 89d1ab2d
# frozen_string_literal: true
class AddClusterIdLocationIndexToVulnerabilityOccurrences < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'index_vulnerability_occurrences_on_location_cluster_id'
def up
add_concurrent_index :vulnerability_occurrences, "(location -> 'cluster_id')",
using: 'GIN',
where: 'report_type = 7',
name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME
end
end
b5fbbfe186b3eeeb88bfd901ac426fc52355b71b67c5f5b42373008c19c35bee
\ No newline at end of file
...@@ -27063,6 +27063,8 @@ CREATE INDEX index_vulnerability_occurrences_deduplication ON vulnerability_occu ...@@ -27063,6 +27063,8 @@ CREATE INDEX index_vulnerability_occurrences_deduplication ON vulnerability_occu
CREATE INDEX index_vulnerability_occurrences_for_issue_links_migration ON vulnerability_occurrences USING btree (project_id, report_type, encode(project_fingerprint, 'hex'::text)); CREATE INDEX index_vulnerability_occurrences_for_issue_links_migration ON vulnerability_occurrences USING btree (project_id, report_type, encode(project_fingerprint, 'hex'::text));
CREATE INDEX index_vulnerability_occurrences_on_location_cluster_id ON vulnerability_occurrences USING gin (((location -> 'cluster_id'::text))) WHERE (report_type = 7);
CREATE INDEX index_vulnerability_occurrences_on_location_image ON vulnerability_occurrences USING gin (((location -> 'image'::text))) WHERE (report_type = ANY (ARRAY[2, 7])); CREATE INDEX index_vulnerability_occurrences_on_location_image ON vulnerability_occurrences USING gin (((location -> 'image'::text))) WHERE (report_type = ANY (ARRAY[2, 7]));
CREATE INDEX index_vulnerability_occurrences_on_primary_identifier_id ON vulnerability_occurrences USING btree (primary_identifier_id); CREATE INDEX index_vulnerability_occurrences_on_primary_identifier_id ON vulnerability_occurrences USING btree (primary_identifier_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