Skip to content

Remove N+1 queries when checking nodes visible to user

username-removed-443319 requested to merge fix-n-plus-one-project-features into master

What does this MR do?

There was an N+1 query situation when checking the nodes visible to a user for MRs. Issues use Ability#issues_visible_to_user, but merge requests don't. (This will change with https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10515 anyway.) That means that MRs use can?, which needs to load the project features, too.

Are there points in the code the reviewer needs to double check?

Don't think so.

Why was this MR needed?

N was small in this case (number of projects), so this would only be a big problem if there were lots of references to MRs in different projects. Still, it looks dumb in the query output.

Merge request reports