Backfill to exclude uploads_size from storage_size for Gitlab.com
What does this MR do and why?
- Added Background migration to backfill storage_size after excluding uploads_size for all existing ProjectStatistics where uploads_size is non-zero.
- Also trigger refresh for RootNamespaceStatistics so that the corresponding changes get updated even for the Namespace
ref: https://gitlab.com/gitlab-org/gitlab/-/issues/370313
This is the second part of the change, the first MR adds a temporary index on ProjectStatistics table to optimise the query time. QueryPlan for same can be found here
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Database Query
Index was added to ProjectStatistics table for optimising the performance of this Migration, the details for the same can be found here
Got production values for one "each_batch" query to check performance
SELECT "project_statistics".* FROM "project_statistics" WHERE "project_statistics"."project_id" BETWEEN 4373 AND 752208 AND "project_statistics"."uploads_size" != 0 AND "project_statistics"."project_id" >= 1
Query Performance
Recommendations:
Link
https://console.postgres.ai/shared/bb136843-f74f-4037-a138-7247587e26da
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.