Preload `avatar_url` for CompareController
What does this MR do and why?
Contributes to #363879 (closed)
Problem
We load all avatars of forked projects and that causes a performance problem.
(source https://gitlab.com/gitlab-org/gitlab/-/compare)
Solution
By default we use batch loading for avatars, but in this case we want
to avoid that. I call avatar_url
method early to change the order of
the batch load and fix the unoptimized query that fetches all avatars of
project's forks.
Screenshots or screen recordings
Before | After |
---|---|
Explanation
The query before the fix contains upload paths to original project (id: 4) and forked project (id: 64). For projects with many forks the query will have uploads paths of all of them in the WHERE
. But we need the avatar of the original project only and we don't display avatars of forked projects.
The query after the fix correctly fetches only paths of the original project.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.