Skip to content

Add migration to create index on vulnerability reads

mo khan requested to merge 382625/add-index-synchronously into master

What does this MR do and why?

We need to be able to find all vulnerabilities for a project that are on the default branch and were detected by a specific scanner. To accomplish that, this MR introduces a sync migration to create a composite database index on vulnerability_reads(project_id, scanner_id, vulnerability_id). The work in this MR is based on the work merged in !110700 (merged).

SELECT "vulnerabilities".*
FROM "vulnerabilities"
INNER JOIN "vulnerability_reads" "vulnerability_read"
  ON "vulnerability_read"."vulnerability_id" = "vulnerabilities"."id"
WHERE "vulnerability_read"."project_id" = 1216
  AND "vulnerability_read"."scanner_id" = 489;

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/15140/commands/52583

Additional context can be found in #382625 (closed).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by mo khan

Merge request reports

Loading