From 87b0d2bc6cd56b1c4891d472f5c951af10d8ac38 Mon Sep 17 00:00:00 2001 From: Tiger <twatson@gitlab.com> Date: Thu, 30 Jun 2022 14:55:34 +1000 Subject: [PATCH] Index vulnerability_reads on casted_cluster_agent_id Changelog: fixed --- ...ty_reads_on_casted_cluster_agent_id_full.rb | 18 ++++++++++++++++++ db/schema_migrations/20220630050050 | 1 + db/structure.sql | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb create mode 100644 db/schema_migrations/20220630050050 diff --git a/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb b/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb new file mode 100644 index 0000000000000..58b6342e30f5b --- /dev/null +++ b/db/post_migrate/20220630050050_index_vulnerability_reads_on_casted_cluster_agent_id_full.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class IndexVulnerabilityReadsOnCastedClusterAgentIdFull < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_vuln_reads_on_casted_cluster_agent_id_where_it_is_null' + + def up + add_concurrent_index :vulnerability_reads, + :casted_cluster_agent_id, + name: INDEX_NAME, + where: 'casted_cluster_agent_id IS NOT NULL' + end + + def down + remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME + end +end diff --git a/db/schema_migrations/20220630050050 b/db/schema_migrations/20220630050050 new file mode 100644 index 0000000000000..2ec998847eb05 --- /dev/null +++ b/db/schema_migrations/20220630050050 @@ -0,0 +1 @@ +dfb314ef76efc54a2464e6b84e71753caf58bc8508f9e64b403066ea4847fe56 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 817e0795f2f3f..8ee7d12ede83f 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -29909,6 +29909,8 @@ COMMENT ON INDEX index_verification_codes_on_phone_and_visitor_id_code IS 'JiHu- CREATE UNIQUE INDEX index_vuln_historical_statistics_on_project_id_and_date ON vulnerability_historical_statistics USING btree (project_id, date); +CREATE INDEX index_vuln_reads_on_casted_cluster_agent_id_where_it_is_null ON vulnerability_reads USING btree (casted_cluster_agent_id) WHERE (casted_cluster_agent_id IS NOT NULL); + CREATE INDEX index_vuln_reads_on_project_id_state_severity_and_vuln_id ON vulnerability_reads USING btree (project_id, state, severity, vulnerability_id DESC); CREATE INDEX index_vulnerabilites_common_finder_query ON vulnerabilities USING btree (project_id, state, report_type, severity, id); -- GitLab