Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/groups/accepting_project_shares_finder.rb')
-rw-r--r--app/finders/groups/accepting_project_shares_finder.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/finders/groups/accepting_project_shares_finder.rb b/app/finders/groups/accepting_project_shares_finder.rb
index c85e5a0f538..cf20292318e 100644
--- a/app/finders/groups/accepting_project_shares_finder.rb
+++ b/app/finders/groups/accepting_project_shares_finder.rb
@@ -42,7 +42,12 @@ module Groups
# rubocop: disable CodeReuse/Finder
def groups_with_guest_access_plus
- GroupsFinder.new(current_user, min_access_level: Gitlab::Access::GUEST).execute
+ groups = GroupsFinder.new(current_user, min_access_level: Gitlab::Access::GUEST).execute
+
+ # We move the result into a materialized CTE to improve query performance during text search.
+ union_query = ::Group.from_union([groups])
+ cte = Gitlab::SQL::CTE.new(:my_union_cte, union_query)
+ Group.with(cte.to_arel).from(cte.alias_to(Group.arel_table)) # rubocop: disable CodeReuse/ActiveRecord -- CTE use
end
# rubocop: enable CodeReuse/Finder