Commit 1ad3c57b authored by João Alexandre Cunha's avatar João Alexandre Cunha

Merge branch '355703-add-index-to-vulnerability_reads' into 'master'

Add index to improve speed of vulnerability_reads

See merge request gitlab-org/gitlab!82942
parents 4e340e22 66dcd5b3
# frozen_string_literal: true
class AddIndexToVulnerabilityReads < Gitlab::Database::Migration[1.0]
INDEX_NAME = 'index_vulnerability_reads_common_finder_query'
disable_ddl_transaction!
def up
add_concurrent_index(
:vulnerability_reads,
%i[project_id state report_type severity vulnerability_id],
name: INDEX_NAME,
order: { vulnerability_id: :desc }
)
end
def down
remove_concurrent_index_by_name(
:vulnerability_reads,
INDEX_NAME
)
end
end
ae734a1ae3555a237e427dbcc0ace6c461c50cf98bc1076ca59c90b603b88c29
\ No newline at end of file
......@@ -29437,6 +29437,8 @@ CREATE UNIQUE INDEX index_vulnerability_occurrences_on_uuid ON vulnerability_occ
CREATE INDEX index_vulnerability_occurrences_on_vulnerability_id ON vulnerability_occurrences USING btree (vulnerability_id);
CREATE INDEX index_vulnerability_reads_common_finder_query ON vulnerability_reads USING btree (project_id, state, report_type, severity, vulnerability_id DESC);
CREATE INDEX index_vulnerability_reads_on_cluster_agent_id ON vulnerability_reads USING btree (cluster_agent_id) WHERE (report_type = 7);
CREATE INDEX index_vulnerability_reads_on_location_image ON vulnerability_reads USING btree (location_image) WHERE (report_type = ANY (ARRAY[2, 7]));
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