Skip to content

MembersFinder contains slow database query with OR conditions

This is a follow-up from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28887#note_188562442:

The MembersFinder query contains a OR condition that can be replaced by using UNION instead. This brings runtime down by at least one order of magnitude.

More background for this change is here: https://www.youtube.com/watch?v=SlJoSCM19Uc

The proposed query is https://gitlab.com/gitlab-org/gitlab-ce/snippets/1871887, notice the members.id IN (... UNION ...) part. The current query can be found in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28887#note_186203636.