Commit 9d0c4fb7 authored by Stan Hu's avatar Stan Hu

Use `Namespace#all_projects` for NPM package finder

In https://gitlab.com/gitlab-com/gl-infra/production/-/issues/3894, we
found that query plans using `base_and_descendants` as a subquery in an
`IN ()` clause may trigger a PostgreSQL v11 query planner bug, resulting
in a significant performance degradation.

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56078 works around
this issue by moving the clause into a INNER JOIN, but finders may have
to take advantage of this by calling `Group#all_projects` instead of
`base_and_descendants`.

This is a similar fix to
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56346.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/324220
parent 2f6a0588
......@@ -35,8 +35,7 @@ module Packages
end
def packages_for_namespace
projects = ::Project.in_namespace(@namespace.self_and_descendants.select(:id))
::Packages::Package.for_projects(projects.select(:id))
::Packages::Package.for_projects(@namespace.all_projects)
end
end
end
......
---
title: Use `Namespace#all_projects` for NPM package finder
merge_request: 56415
author:
type: performance
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