From 5e4163b53b0d67d7cb98134331c418dca95747f3 Mon Sep 17 00:00:00 2001 From: "stonezdj(Daojun Zhang)" Date: Thu, 20 Jul 2023 14:00:40 +0800 Subject: [PATCH] Create index in vulnerability_record table (#18949) add index for better query performance Signed-off-by: stonezdj --- make/migrations/postgresql/0120_2.9.0_schema.up.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/make/migrations/postgresql/0120_2.9.0_schema.up.sql b/make/migrations/postgresql/0120_2.9.0_schema.up.sql index 571f9850b4d..a44d26fdf33 100644 --- a/make/migrations/postgresql/0120_2.9.0_schema.up.sql +++ b/make/migrations/postgresql/0120_2.9.0_schema.up.sql @@ -12,6 +12,10 @@ SET cvss_score_v3 = (vendor_attributes->'CVSS'->'nvd'->>'V3Score')::double preci WHERE jsonb_path_exists(vendor_attributes::jsonb, '$.CVSS.nvd.V3Score'); CREATE INDEX IF NOT EXISTS idx_vulnerability_record_cvss_score_v3 ON vulnerability_record (cvss_score_v3); +CREATE INDEX IF NOT EXISTS idx_vulnerability_registration_uuid ON vulnerability_record (registration_uuid); +CREATE INDEX IF NOT EXISTS idx_vulnerability_record_cve_id ON vulnerability_record (cve_id); +CREATE INDEX IF NOT EXISTS idx_vulnerability_record_severity ON vulnerability_record (severity); +CREATE INDEX IF NOT EXISTS idx_vulnerability_record_package ON vulnerability_record (package); /* add summary information in scan_report */ ALTER TABLE scan_report ADD COLUMN IF NOT EXISTS critical_cnt BIGINT;