Reduce N+1 project queries in merge_request_diff

What does this MR do and why?

While I was looking at reducing the number of queries for !210454 (merged) to address failing spec, I noticed lots of project lookups coming from this feature flag check as it was called for each diff.

The original change had been introduced in !203146 (merged)

Query count:

  • Before: 257
  • After: 217

NOTE: I intentionally didn't reduce the query count linit in the spec and I'll update it later once !210454 (merged) gets merged.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

MR acceptance checklist

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

Edited by Sincheol (David) Kim

Merge request reports

Loading