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 0000000000000000000000000000000000000000..58b6342e30f5b3cd6f2147f5e6659bb5990e7fd2 --- /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 0000000000000000000000000000000000000000..2ec998847eb05307e8956973f6999e9edf93e168 --- /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 817e0795f2f3f33a6e402e24820da971a0daaac8..8ee7d12ede83f206039aef21b15a20d45b40b7eb 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);