N+1 Queries in vulnerability exports

Why are we doing this work

Ref: #432548 (comment 1694930046)

We did profiling of vulnerability export generation. We can see that for each row, we are spending a lot of time in vulnerability.full_path, vulnerability.group_name, vulnerability.notes_summary, and vulnerability.project_name, and there are hits to database classes inside these nodes. This indicates that we have N+1 queries when reading these fields.

Screenshot_2023-12-14_at_10.42.53_AM

For group exports that have thousands of vulnerabilities, this is probably making the export literally 20-50 times slower.

Relevant links

Non-functional requirements

  • Documentation:
  • Feature flag:
  • Performance:
  • Testing:

Implementation plan

Verification steps