Skip to content

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:

  1. It times out and returns -1 on .com
  2. It does not provide the data that ~"group::import" needs, so it needs to be updated
  3. 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

Availability and Testing

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

Merge request reports