Update projects_imported.total usage ping
What does this MR do?
This MR updates usage_activity_by_stage_monthly.manage.projects_imported.total
usage ping since:
- It times out and returns -1 on .com
- It does not provide the data that ~"group::import" needs, so it needs to be updated
- More accurate metric was requested in #283175 (closed) which after a discussion resulted in updating existing one
Had to add a new index on projects table because new query was taking ~13 seconds to complete. With new index it takes ~200ms on 10k batch. Execution plan below.
Mentions #291984 (closed)
Migration output
Up
== 20201210101250 AddIndexProjectsOnImportTypeAndCreatorId: migrating =========
-- transaction_open?()
-> 0.0000s
-- index_exists?(:projects, [:creator_id, :import_type, :created_at], {:where=>"import_type IS NOT NULL", :name=>"index_projects_on_creator_id_import_type_and_created_at_partial", :algorithm=>:concurrently})
-> 0.0156s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- add_index(:projects, [:creator_id, :import_type, :created_at], {:where=>"import_type IS NOT NULL", :name=>"index_projects_on_creator_id_import_type_and_created_at_partial", :algorithm=>:concurrently})
-> 0.0055s
-- execute("RESET ALL")
-> 0.0003s
== 20201210101250 AddIndexProjectsOnImportTypeAndCreatorId: migrated (0.0222s)
Down
== 20201210101250 AddIndexProjectsOnImportTypeAndCreatorId: reverting =========
-- transaction_open?()
-> 0.0000s
-- indexes(:projects)
-> 0.0216s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- remove_index(:projects, {:algorithm=>:concurrently, :name=>"index_projects_on_creator_id_import_type_and_created_at_partial"})
-> 0.0041s
-- execute("RESET ALL")
-> 0.0002s
== 20201210101250 AddIndexProjectsOnImportTypeAndCreatorId: reverted (0.0268s)
Execution plan
With created_at: https://explain.depesz.com/s/B9T1
Without created_at: https://explain.depesz.com/s/BiGQ
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
Edited by George Koltsov