Add instrumentation classes for Deployment metrics
What does this MR do and why?
We're removing UsageData
class, this MR adds instrumentation class for Deployments
metrics and removes the old code from usage_data
.
Note, this MR doesn't affect usage_activity_by_stage
metrics which also counts Deployment, but performs distinct
counts instead
DB review info
The metric produces queries:
"SELECT COUNT(\"deployments\".\"id\") FROM \"deployments\""
Finalize Aggregate (cost=7156367.01..7156367.02 rows=1 width=8)
-> Gather (cost=7156366.79..7156367.00 rows=2 width=8)
Workers Planned: 2
-> Partial Aggregate (cost=7155366.79..7155366.80 rows=1 width=8)
-> Parallel Index Only Scan using index_deployments_on_environment_id_and_id on deployments (cost=0.57..6674541.56 rows=192330095 width=4)
"SELECT COUNT(\"deployments\".\"id\") FROM \"deployments\" WHERE \"deployments\".\"created_at\" BETWEEN '2023-05-13 07:50:35.127381' AND '2023-06-10 07:50:35.127623'"
Finalize Aggregate (cost=6048180.49..6048180.50 rows=1 width=8)
-> Gather (cost=6048180.28..6048180.49 rows=2 width=8)
Workers Planned: 2
-> Partial Aggregate (cost=6047180.28..6047180.29 rows=1 width=8)
-> Parallel Index Scan using index_deployments_on_created_at on deployments (cost=0.57..6032948.74 rows=5692615 width=4)
In
"SELECT COUNT(\"deployments\".\"id\") FROM \"deployments\" WHERE \"deployments\".\"status\" = 2 AND \"deployments\".\"created_at\" BETWEEN '2023-05-13 07:50:50.611722' AND '2023-06-10 07:50:50.611924'"
Finalize Aggregate (cost=6053792.81..6053792.82 rows=1 width=8)
-> Gather (cost=6053792.59..6053792.80 rows=2 width=8)
Workers Planned: 2
-> Partial Aggregate (cost=6052792.59..6052792.60 rows=1 width=8)
-> Parallel Index Scan using index_deployments_on_created_at on deployments (cost=0.57..6047167.41 rows=2250075 width=4)
Execution plans:
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #409632 (closed)
Edited by Niko Belokolodov