diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 21980a5e1b79d52fca9e33ae22540e3be36e3ab7..f1aeb7e528f2a91719083e168612744531e418cf 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -86,7 +86,7 @@ class CommitStatus < Ci::ApplicationRecord scope :for_project_paths, -> (paths) do # Pluck is used to split this query. Splitting the query is required for database decomposition for `ci_*` tables. # https://docs.gitlab.com/ee/development/database/transaction_guidelines.html#database-decomposition-and-sharding - project_ids = Project.where_full_path_in(Array(paths)).pluck(:id) + project_ids = Project.where_full_path_in(Array(paths), use_includes: false).pluck(:id) for_project(project_ids) end diff --git a/app/services/clusters/agents/authorizations/user_access/refresh_service.rb b/app/services/clusters/agents/authorizations/user_access/refresh_service.rb index 04d6e04c54daa632217574e63e48e93fa2712808..7efa95739fbe4c8d671a228ee71a6d2be2369118 100644 --- a/app/services/clusters/agents/authorizations/user_access/refresh_service.rb +++ b/app/services/clusters/agents/authorizations/user_access/refresh_service.rb @@ -59,7 +59,7 @@ def allowed_project_configurations return unless project_entries - allowed_projects.where_full_path_in(project_entries.keys).map do |project| + allowed_projects.where_full_path_in(project_entries.keys, use_includes: false).map do |project| { project_id: project.id, config: user_access_as } end end @@ -70,7 +70,7 @@ def allowed_group_configurations return unless group_entries - allowed_groups.where_full_path_in(group_entries.keys).map do |group| + allowed_groups.where_full_path_in(group_entries.keys, use_includes: false).map do |group| { group_id: group.id, config: user_access_as } end end diff --git a/lib/gitlab/cleanup/project_uploads.rb b/lib/gitlab/cleanup/project_uploads.rb index 6feaab2a791901a6bdd1650a3d7cc0c6e086ccc5..918f723cd60c676b4d254509a0023e823b1922be 100644 --- a/lib/gitlab/cleanup/project_uploads.rb +++ b/lib/gitlab/cleanup/project_uploads.rb @@ -122,7 +122,7 @@ def orphan? # rubocop: disable CodeReuse/ActiveRecord def project_id - @project_id ||= Project.where_full_path_in([full_path]).pluck(:id) + @project_id ||= Project.where_full_path_in([full_path], use_includes: false).pluck(:id) end # rubocop: enable CodeReuse/ActiveRecord end diff --git a/lib/gitlab/graphql/loaders/full_path_model_loader.rb b/lib/gitlab/graphql/loaders/full_path_model_loader.rb index a99b8c81930590d840c73653522f418209c0300e..d0ec403432c4acbbac4c35223d57f61215c2eb8c 100644 --- a/lib/gitlab/graphql/loaders/full_path_model_loader.rb +++ b/lib/gitlab/graphql/loaders/full_path_model_loader.rb @@ -20,8 +20,7 @@ def find # this logic cannot be placed in the NamespaceResolver due to N+1 scope = scope.without_project_namespaces if scope == Namespace # `with_route` avoids an N+1 calculating full_path - scope = scope.where_full_path_in(full_paths).with_route - .allow_cross_joins_across_databases(url: "https://gitlab.com/gitlab-org/gitlab/-/issues/420046") + scope = scope.where_full_path_in(full_paths) scope.each do |model_instance| loader.call(model_instance.full_path.downcase, model_instance)