Skip to content

Fix N+1 queries for non-members in comment threads

What does this MR do?

Remove a query we were running per comment in threads for people who weren't project members. This is because they will have no access results, and so they won't be present in the cache.

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

The specs do create a lot of DB objects, so they might need to be bundled together.

Why was this MR needed?

Look at http://profiler.gitlap.com/20170530/c00e298a-1f03-4031-bd08-630b2d3cd9b3.txt.gz. This will remove one query per non-project-member comment in https://gitlab.com/gitlab-org/gitlab-ce/issues/22484, which adds up to quite a lot!

Merge request reports