Improve performance of index action for Projects::CompareController
Problem
https://gitlab.com/gitlab-org/gitlab/-/compare is slow.
Description
The performance problem is caused by a DB query that loads avatars for all fetch projects on this page.
We load all forked projects on compare page to show their names in the select box. But that also triggers avatar loading for each of them (because of after_initialize
for Project model). For projects with many forks this query becomes a performance problem.
Proposal
Load avatars only for the current project and its namespace.