Commit 44e892e7 authored by Sashi's avatar Sashi

Add index for vulnerability_occurrences image location

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

Changelog: performance
parent 97f3119a
# frozen_string_literal: true
class AddImageLocationIndexToVulnerabilityOccurrences < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'index_vulnerability_occurrences_on_location_image'
def up
add_concurrent_index :vulnerability_occurrences, "(location -> 'image')",
using: 'GIN',
where: 'report_type IN (2, 7)',
name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME
end
end
ae98a673b649faf8644990de328470579e121544d4fc417562cc64a7687550ca
\ No newline at end of file
......@@ -26809,6 +26809,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_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_project_fingerprint ON vulnerability_occurrences USING btree (project_fingerprint);
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