Commit fc609e6c authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'sh-restrict-cte-project-dashboard' into 'master'

Restrict use of CTE fence to dashboards/projects#index

Closes #201994

See merge request gitlab-org/gitlab!24408
parents 188d23bf a061a454
...@@ -66,7 +66,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController ...@@ -66,7 +66,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
@total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute @total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute
@total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute @total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute
finder_params[:use_cte] = Feature.enabled?(:use_cte_for_projects_finder, default_enabled: true) finder_params[:use_cte] = true if use_cte_for_finder?
projects = ProjectsFinder projects = ProjectsFinder
.new(params: finder_params, current_user: current_user) .new(params: finder_params, current_user: current_user)
...@@ -79,6 +79,11 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController ...@@ -79,6 +79,11 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def use_cte_for_finder?
# The starred action loads public projects, which causes the CTE to be less efficient
action_name == 'index' && Feature.enabled?(:use_cte_for_projects_finder, default_enabled: true)
end
def load_events def load_events
projects = load_projects(params.merge(non_public: true)) projects = load_projects(params.merge(non_public: true))
......
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