Store pipeline counts by status
What does this MR do?
This MR periodically stores pipeline counts by status for the instance statistics feature.
The change is behind a feature flag (store_ci_pipeline_counts_by_status
) which is currently disabled by default.
In order to make counts efficient (BatchCount), an existing index had to be modified to include the id
attribute.
The index creation took 17 minutes.
Queries
The queries are executed by BatchCount
. The newly created index should cover all 4 cases (succeeded, failed, skipped, canceled).
SELECT MIN("ci_pipelines"."id") FROM "ci_pipelines" WHERE ("ci_pipelines"."status" IN ('canceled'))
Plan: https://explain.depesz.com/s/LHXG
SELECT MAX("ci_pipelines"."id") FROM "ci_pipelines" WHERE ("ci_pipelines"."status" IN ('canceled'))
Plan: https://explain.depesz.com/s/tHbu
SELECT COUNT("ci_pipelines"."id") FROM "ci_pipelines" WHERE ("ci_pipelines"."status" IN ('canceled')) AND "ci_pipelines"."id" BETWEEN 1200056 AND 1300055
Plan: https://explain.depesz.com/s/lAxd
GraphQL query for the counts
You can create seed data by running: FILTER=instance_statistics bundle exec rake db:seed_fu
{
instanceStatisticsMeasurements(identifier: PIPELINES_SUCCEEDED) {
nodes {
count
recordedAt
}
}
}
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
- [-] Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
Counts are exposed for admins only.
Refs #246847 (closed)
Edited by Peter Leitzen