Commit 823805b5 authored by Jarka Košanová's avatar Jarka Košanová

Merge branch...

Merge branch '342715-db-timeout-when-loading-environment-in-projects-blobcontroller-show-2' into 'master'

Optimize EnvironmentsByDeploymentsFinder query

See merge request gitlab-org/gitlab!74526
parents cc2f3a8c 11fb7376
......@@ -24,9 +24,10 @@ module Environments
end
environments =
if Feature.enabled?(:environments_by_deployments_finder_exists_optimization, default_enabled: :yaml)
if Feature.enabled?(:environments_by_deployments_finder_exists_optimization, project, default_enabled: :yaml)
# TODO: replace unscope with deployments = Deployment on top of the method https://gitlab.com/gitlab-org/gitlab/-/issues/343544
project.environments.available
.where('EXISTS (?)', deployments.where('environment_id = environments.id'))
.where('EXISTS (?)', deployments.unscope(where: :project_id).where('environment_id = environments.id'))
else
environment_ids = deployments
.group(:environment_id)
......
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