Commit 5f46d0b1 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '208923-enable-batch-counting-for-some-individual-queries-5' into 'master'

Optimize projects_with_prometheus_alerts query

See merge request gitlab-org/gitlab!27544
parents 5b6f3792 db42b6d6
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
class PrometheusAlert < ApplicationRecord class PrometheusAlert < ApplicationRecord
include Sortable include Sortable
include UsageStatistics
OPERATORS_MAP = { OPERATORS_MAP = {
lt: "<", lt: "<",
......
...@@ -155,7 +155,7 @@ module EE ...@@ -155,7 +155,7 @@ module EE
projects_mirrored_with_pipelines_enabled: count(::Project.mirrored_with_enabled_pipelines), projects_mirrored_with_pipelines_enabled: count(::Project.mirrored_with_enabled_pipelines),
projects_reporting_ci_cd_back_to_github: count(::GithubService.without_defaults.active), projects_reporting_ci_cd_back_to_github: count(::GithubService.without_defaults.active),
projects_with_packages: count(::Packages::Package.select('distinct project_id'), batch: false), projects_with_packages: count(::Packages::Package.select('distinct project_id'), batch: false),
projects_with_prometheus_alerts: count(PrometheusAlert.distinct_projects, batch: false), projects_with_prometheus_alerts: distinct_count(PrometheusAlert, :project_id),
projects_with_tracing_enabled: count(ProjectTracingSetting), projects_with_tracing_enabled: count(ProjectTracingSetting),
template_repositories: count(::Project.with_repos_templates, batch: false) + count(::Project.with_groups_level_repos_templates, batch: false) template_repositories: count(::Project.with_repos_templates, batch: false) + count(::Project.with_groups_level_repos_templates, batch: false)
}, },
......
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