Add limit constraint on frameworks and requirements
What does this MR do and why?
Currently there is no limit on
- no. of frameworks which can be associated with each project.
- 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:
- Maximum 20 frameworks per project.
- 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