Skip to content

Index vulnerabilities on project_id, state and severity columns

What does this MR do?

This MR introduces a new index for the vulnerabilities table on project_id, state, and severity columns.

The new index will be utilized by the Vulnerabilities::Statistics::AdjustmentService here.

Related to #227765 (closed)

Database review

rake db:migrate

== 20201201175656 AddIndexVulnerabilitiesOnProjectIdAndStateAndSeverity: migrating
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:vulnerabilities, [:project_id, :state, :severity], {:name=>"index_vulnerabilities_on_project_id_and_state_and_severity", :algorithm=>:concurrently})
   -> 0.0030s
-- add_index(:vulnerabilities, [:project_id, :state, :severity], {:name=>"index_vulnerabilities_on_project_id_and_state_and_severity", :algorithm=>:concurrently})
   -> 0.0019s
== 20201201175656 AddIndexVulnerabilitiesOnProjectIdAndStateAndSeverity: migrated (0.0054s)


== 20201202142751 DropIndexVulnerabilitiesOnProjectId: migrating ==============
-- transaction_open?()
   -> 0.0000s
-- indexes(:vulnerabilities)
   -> 0.0058s
-- remove_index(:vulnerabilities, {:algorithm=>:concurrently, :name=>"index_vulnerabilities_on_project_id"})
   -> 0.0051s
== 20201202142751 DropIndexVulnerabilitiesOnProjectId: migrated (0.0114s) =====

rake db:migrate:down

== 20201202142751 DropIndexVulnerabilitiesOnProjectId: reverting ==============
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:vulnerabilities, :project_id, {:name=>"index_vulnerabilities_on_project_id", :algorithm=>:concurrently})
   -> 0.0052s
-- add_index(:vulnerabilities, :project_id, {:name=>"index_vulnerabilities_on_project_id", :algorithm=>:concurrently})
   -> 0.0070s
== 20201202142751 DropIndexVulnerabilitiesOnProjectId: reverted (0.0125s) =====


== 20201201175656 AddIndexVulnerabilitiesOnProjectIdAndStateAndSeverity: reverting
-- transaction_open?()
   -> 0.0000s
-- indexes(:vulnerabilities)
   -> 0.0057s
-- remove_index(:vulnerabilities, {:algorithm=>:concurrently, :name=>"index_vulnerabilities_on_project_id_and_state_and_severity"})
   -> 0.0020s
== 20201201175656 AddIndexVulnerabilitiesOnProjectIdAndStateAndSeverity: reverted (0.0084s)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Mehmet Emin INAC

Merge request reports