Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit 1627f4ef authored by Andreas Brandl's avatar Andreas Brandl
Browse files

Replace OR clause with UNION.

parent c3ee1cfbb803
......@@ -325,7 +325,13 @@ def self.public_or_visible_to_user(user = nil)
levels = Gitlab::VisibilityLevel.levels_for_user(user)
where('EXISTS (?) OR projects.visibility_level IN (?)', authorized, levels)
authorized_projects = where('EXISTS (?)', authorized).select(:id)
visible_projects = where('visibility_level IN (?)', levels).select(:id)
# We use a UNION here instead of OR clauses since this results in better
# performance.
union = Gitlab::SQL::Union.new([authorized_projects, visible_projects])
where("projects.id IN (#{union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection
else
public_to_user
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment