Create compound index for vulnerabilities table on project_id, severity & state
We can also create a partial index only for states
(1, 4) which will make the index size smaller.
backend add index on
CREATE INDEX index_vulnerabilities_on_project_id_state_and_severity ON public.vulnerabilities USING btree (project_id, state, severity);
backend consider creating partial index instead to cover only 1 and 4 states (