Skip to content

Add limit constraint on frameworks and requirements

Hitesh Raghuvanshi requested to merge 482489-add-constraints into master

What does this MR do and why?

Currently there is no limit on

  1. no. of frameworks which can be associated with each project.
  2. no. of compliance requirements associated with a compliance framework.

Which is not ideal as it may lead to degraded query performances.

It was decided with @nrosandich and @theoretick that we will add following limits on these associations:

  1. Maximum 20 frameworks per project.
  2. Maximum 50 requirements per framework.

We can increase these numbers in future.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Queries

Query 1: Count of requirements per framework

Note: Currently there are no entries in compliance_requirements table but we have a composite unique index on framework_id and name column.

Query plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/32382/commands/100034

Query:

SELECT COUNT(*) FROM "compliance_requirements" WHERE "compliance_requirements"."framework_id" = 1020183;

Query 2: Count of frameworks associated per project

Query plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/32382/commands/100033

Query:

SELECT COUNT(*) FROM "project_compliance_framework_settings" WHERE "project_compliance_framework_settings"."project_id" = 61867019;

Related to #482489 (closed) https://gitlab.com/gitlab-org/gitlab/-/issues/499056

Edited by Nate Rosandich

Merge request reports

Loading