N+1 queries loading award emojis
In http://profiler.gitlap.com/20180322/e13f63e1-f91b-41c1-9234-244189201a7c.html.gz, you can see the call to grouped_awards
for each note is causing about 8% of the load time in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9546
.
It's happen in two places: once for each note in the issue, and once for each diff discussion.
This also relates to https://gitlab.com/gitlab-org/gitlab-ce/issues/23241 since calling grouped_awards
once is slow. CollectionAssociation#scope
is slow due to a Rails 4 issue: https://github.com/rails/rails/issues/25970.