Calling Awardable#grouped_awards is slow even when no emoji are present
Currently 5% of the time of issue 1 is consumed by Awardable#grouped_awards
:
What gets me is that NONE of the notes have any emoji in them at all. Except we call this method 70+ times for each note.
Why is this slow? At first, I suspected we may be making database calls for each note, but that it is not the case. It looks to me that the notes eager load the award emoji via:
raw_notes = @issue.notes.inc_relations_for_view.fresh
So what is happening here? I suspect https://github.com/rails/rails/issues/25970 is what we're seeing here: CollectionAssociation#scope
is slow.
What can we do instead? Can we just extract the emoji name and count? I'm not sure if we can do much here other than patch Rails.
/cc: @pacoguzman, @yorickpeterse
Edited by 🤖 GitLab Bot 🤖