Limit CI builds queries to 7 days

This applies to EE queries only. It improves performance of those
queries significantly.

Related to https://gitlab.com/gitlab-org/gitlab-exporter/issues/58
parent 4f93afa4
Pipeline #125290 passed with stage
in 52 seconds
PATH PATH
remote: . remote: .
specs: specs:
gitlab-exporter (4.2.0) gitlab-exporter (5.0.1)
connection_pool (~> 2.2.1) connection_pool (~> 2.2.1)
pg (~> 1.1) pg (~> 1.1)
quantile (~> 0.2.0) quantile (~> 0.2.0)
...@@ -23,7 +23,7 @@ GEM ...@@ -23,7 +23,7 @@ GEM
powerpack (0.1.1) powerpack (0.1.1)
quantile (0.2.1) quantile (0.2.1)
rack (2.0.7) rack (2.0.7)
rack-protection (2.0.5) rack-protection (2.0.7)
rack rack
rainbow (2.1.0) rainbow (2.1.0)
redis (4.1.2) redis (4.1.2)
...@@ -54,10 +54,10 @@ GEM ...@@ -54,10 +54,10 @@ GEM
rack (>= 1.5.0) rack (>= 1.5.0)
rack-protection (>= 1.5.0) rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 5) redis (>= 3.3.5, < 5)
sinatra (2.0.5) sinatra (2.0.7)
mustermann (~> 1.0) mustermann (~> 1.0)
rack (~> 2.0) rack (~> 2.0)
rack-protection (= 2.0.5) rack-protection (= 2.0.7)
tilt (~> 2.0) tilt (~> 2.0)
tilt (2.0.9) tilt (2.0.9)
unicode-display_width (1.1.0) unicode-display_width (1.1.0)
......
...@@ -25,6 +25,8 @@ module GitLab ...@@ -25,6 +25,8 @@ module GitLab
ON application_settings.id = 1 ON application_settings.id = 1
WHERE ci_builds.type = 'Ci::Build' WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status = '%s' AND ci_builds.status = '%s'
-- The created_at filter has been introduced for performance reasons only
AND ci_builds.created_at > NOW() - INTERVAL '7 days'
AND projects.pending_delete = 'f' AND projects.pending_delete = 'f'
GROUP BY GROUP BY
projects.namespace_id, projects.namespace_id,
...@@ -95,6 +97,8 @@ module GitLab ...@@ -95,6 +97,8 @@ module GitLab
ON application_settings.id = 1 ON application_settings.id = 1
WHERE ci_builds.type = 'Ci::Build' WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status = 'running' AND ci_builds.status = 'running'
-- The created_at filter has been introduced for performance reasons only
AND ci_builds.created_at > NOW() - INTERVAL '7 days'
AND projects.pending_delete = 'f' AND projects.pending_delete = 'f'
GROUP BY GROUP BY
ci_builds.runner_id, ci_builds.runner_id,
...@@ -171,6 +175,8 @@ module GitLab ...@@ -171,6 +175,8 @@ module GitLab
ON application_settings.id = 1 ON application_settings.id = 1
WHERE ci_builds.type = 'Ci::Build' WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status IN ('running', 'pending') AND ci_builds.status IN ('running', 'pending')
-- The created_at filter has been introduced for performance reasons only
AND ci_builds.created_at > NOW() - INTERVAL '7 days'
GROUP BY GROUP BY
projects.namespace_id, projects.namespace_id,
projects.shared_runners_enabled, projects.shared_runners_enabled,
......
module GitLab module GitLab
module Exporter module Exporter
VERSION = "5.0.0".freeze VERSION = "5.0.1".freeze
end end
end end
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