Eager loads for `has_many` relations slowing down issue page loads
If we profile https://gitlab.com/gitlab-org/gitlab-ce/issues/1
, we see that 7% of the time in see ruby-prof graph is spent loading Awardable#grouped_awards
even though there are ZERO award emojis present in the issue. There may be many other examples in our code of this.
It appears that a significant amount of time is in ActiveRecord::Associations::CollectionAssociation#scope
:
It appears this is a fairly recent issue identified in Rails 4 and 5: https://github.com/rails/rails/issues/25970. It appears it was recently fixed via https://github.com/rails/rails/pull/25877.
I'm not sure if the changes will be backported to Rails 4 or even 5.0, but I'm creating this issue to document this interesting finding.
Edited by 🤖 GitLab Bot 🤖