Use Goldiloader for handling N+1 queries
What does this MR do?
Adds goldiloader (extracted from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18157). This addresses a particularly bad N+1 issue described in https://gitlab.com/gitlab-org/gitlab-ce/issues/43106#note_64018144
Are there points in the code the reviewer needs to double check?
I haven't had time to dig into why, precisely, but it seems that Goldiloader has problems with through
associations, or associations that are polymorphic where one of the types isn't in the DB (like Todo#target
can be a commit; this is a little weird by us, though).
Should we add this to all through
associations? I just squashed the issues I saw from the test suite.
Why was this MR needed?
https://gitlab.com/gitlab-org/gitlab-ce/issues/43106 isn't fixed by this, but we at least won't run over 1,000 queries on some requests.
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary - Review
-
Has been reviewed by Backend
-
Edited by Yorick Peterse