Account for uploaded files in storage statistics
What does this MR do?
Up to now we have not been taking uploads into consideration for computing total storage usage for repositories. This changes that.
Database
Migrations
UP
== 20201105021637 AddUploadsSizeToProjectStatistics: migrating ================
-- add_column(:project_statistics, :uploads_size, :bigint, {:default=>0, :null=>false})
-> 0.0191s
== 20201105021637 AddUploadsSizeToProjectStatistics: migrated (0.0192s) =======
== 20201105024127 AddUploadsSizeToNamespaceRootStorageStatistics: migrating ===
-- add_column(:namespace_root_storage_statistics, :uploads_size, :bigint, {:default=>0, :null=>false})
-> 0.0017s
== 20201105024127 AddUploadsSizeToNamespaceRootStorageStatistics: migrated (0.0017s)
DOWN
== 20201105024127 AddUploadsSizeToNamespaceRootStorageStatistics: reverting ===
-- remove_column(:namespace_root_storage_statistics, :uploads_size)
-> 0.0135s
== 20201105024127 AddUploadsSizeToNamespaceRootStorageStatistics: reverted (0.0135s)
== 20201105021637 AddUploadsSizeToProjectStatistics: reverting ================
-- remove_column(:project_statistics, :uploads_size)
-> 0.0015s
== 20201105021637 AddUploadsSizeToProjectStatistics: reverted (0.0015s) =======
Queries
Sum of uploads in a project
Explain: https://explain.depesz.com/s/Vov3
Query
SELECT SUM("uploads"."size") FROM "uploads" WHERE "uploads"."model_id" = 278964 AND "uploads"."model_type" = 'Project'
Timings
Time: 1.460 s
- planning: 0.167 ms
- execution: 1.460 s
- I/O read: 1.306 s
- I/O write: 0.000 ms
Shared buffers:
- hits: 6877 (~53.70 MiB) from the buffer pool
- reads: 65484 (~511.60 MiB) from the OS file cache, including disk I/O
- dirtied: 615 (~4.80 MiB)
- writes: 0
Screenshots (strongly suggested)
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
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Related to #241980
Edited by Mayra Cabrera