Skip to content

Include `license_scanning` to Ci::Build index

Tetiana Chupryna requested to merge 198652-update-index-on-license-scanning into master

What does this MR do?

This is a part of #198652 (closed)

We're adding license_scanning artifact file type and we need to update index on Ci::Build so it includes license_scanning as well

RAW SQL

up migration

Duration time: 184 min

CREATE  INDEX CONCURRENTLY "index_ci_builds_on_name_for_security_reports_values" ON "ci_builds"  ("name") WHERE ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('license_scanning'::character varying)::text]))

DROP INDEX CONCURRENTLY "index_ci_builds_on_name_for_security_products_values"

down migration

CREATE  INDEX CONCURRENTLY "index_ci_builds_on_name_for_security_products_values" ON "ci_builds"  ("name") WHERE ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text]))

DROP INDEX CONCURRENTLY "index_ci_builds_on_name_for_security_reports_values"

Migration output

== 20200202204831 UpdateIndexCiBuildsOnNameForSecurityReportsValues: migrating 
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:ci_builds, :name, {:name=>"index_ci_builds_on_name_for_security_reports_values", :where=>"((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('license_scanning'::character varying)::text]))", :algorithm=>:concurrently})
   -> 0.0150s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- add_index(:ci_builds, :name, {:name=>"index_ci_builds_on_name_for_security_reports_values", :where=>"((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('license_scanning'::character varying)::text]))", :algorithm=>:concurrently})
   -> 0.0040s
-- execute("RESET ALL")
   -> 0.0009s
-- transaction_open?()
   -> 0.0000s
-- indexes(:ci_builds)
   -> 0.0133s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- remove_index(:ci_builds, {:algorithm=>:concurrently, :name=>"index_ci_builds_on_name_for_security_products_values"})
   -> 0.0034s
-- execute("RESET ALL")
   -> 0.0008s
== 20200202204831 UpdateIndexCiBuildsOnNameForSecurityReportsValues: migrated (0.0406s)

Usage of this index

This index is used in calculation usage data

explain SELECT Count(*) FROM "ci_builds" WHERE"ci_builds"."type" IN ('Ci::Build') AND "ci_builds"."name" IN ('license_scanning')

Before updating the index

from db-lab

https://explain.depesz.com/s/yitF

After updating the index

from db-lab

https://explain.depesz.com/s/zyUU

More testing

explain SELECT * FROM "ci_builds" WHERE"ci_builds"."type" IN ('Ci::Build') AND "ci_builds"."name" IN ('license_scanning') limit 10

https://explain.depesz.com/s/E4kW

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 🤖 GitLab Bot 🤖

Merge request reports