Address N+1 issues serializing data for the merge request widget
The following discussion from !12357 (merged) should be addressed:
-
@reprazent started a discussion: (+3 comments) As you mentioned yourself https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/12357/diffs#note_167991856.
😁 , I think we might have to do some preloading before turning the MRs into JSON.
@nick.thomas: OK, I've pushed 93269e42 which gets the number of queries back down to "just" 80 or so, but I think this will need a follow-up issue so we can address it more attractively.
In particular, approvals (EE only) are not eagerly loaded.
There is a relation for the API endpoints that uses preload
, which isn't quite what we need. The linked MR modifies the controller to add some includes
statements, but they don't really belong in the controller!