Skip to content

Adds package count to usage data

Giorgenes Gelatti requested to merge 205578-add-package-count-to-usage-data into master

What does this MR do?

Adds packages count under the counts section of usage data for usage ping.

New Query:

Gitlab::UsageData.count(::Packages::Package)
   (103.9ms)  SELECT MIN("packages_packages"."id") FROM "packages_packages"

 Result  (cost=0.45..0.46 rows=1 width=8) (actual time=6.029..6.029 rows=1 loops=1)
   Buffers: shared read=4
   I/O Timings: read=5.926
   InitPlan 1 (returns $0)
     ->  Limit  (cost=0.42..0.45 rows=1 width=8) (actual time=6.024..6.025 rows=1 loops=1)
           Buffers: shared read=4
           I/O Timings: read=5.926
           ->  Index Only Scan using packages_packages_pkey on public.packages_packages  (cost=0.42..7641.76 rows=330019 width=8) (actual time=6.023..6.023 rows=1 loops=1)
                 Index Cond: (packages_packages.id IS NOT NULL)
                 Heap Fetches: 0
                 Buffers: shared read=4
                 I/O Timings: read=5.926
(0.7ms)  SELECT MAX("packages_packages"."id") FROM "packages_packages"

Result  (cost=0.45..0.46 rows=1 width=8) (actual time=8.806..8.806 rows=1 loops=1)
   Buffers: shared hit=2 read=3 dirtied=1
   I/O Timings: read=7.551
   InitPlan 1 (returns $0)
     ->  Limit  (cost=0.42..0.45 rows=1 width=8) (actual time=8.801..8.802 rows=1 loops=1)
           Buffers: shared hit=2 read=3 dirtied=1
           I/O Timings: read=7.551
           ->  Index Only Scan using packages_packages_pkey on public.packages_packages  (cost=0.42..7641.76 rows=330019 width=8) (actual time=8.800..8.800 rows=1 loops=1)
                 Index Cond: (packages_packages.id IS NOT NULL)
                 Heap Fetches: 1
                 Buffers: shared hit=2 read=3 dirtied=1
                 I/O Timings: read=7.551


Recommendations:
:exclamation: VACUUM ANALYZE needed  Visibility map(s) for the table(s) involved in the query are outdated. For better performance: 1) run VACUUM ANALYZE on them as a one-time solution, 2) perform autovacuum tuning as a long-term permanent solution (tuning "vacuum" part of autovacuum).
(0.5ms)  SELECT COUNT("packages_packages"."id") FROM "packages_packages" WHERE "packages_packages"."id" BETWEEN 1 AND 100000

Aggregate  (cost=2212.89..2212.90 rows=1 width=8) (actual time=290.195..290.196 rows=1 loops=1)
   Buffers: shared hit=7 read=275 dirtied=1
   I/O Timings: read=265.087
   ->  Index Only Scan using packages_packages_pkey on public.packages_packages  (cost=0.42..2016.56 rows=78532 width=8) (actual time=0.055..281.439 rows=78472 loops=1)
         Index Cond: ((packages_packages.id >= 1) AND (packages_packages.id <= 100000))
         Heap Fetches: 116
         Buffers: shared hit=7 read=275 dirtied=1

Recommendations:
:exclamation: Query processes too much data to return a relatively small number of rows.  Reduce data cardinality as early as possible during the execution, using one or several of the following techniques: new indexes, partitioning, query rewriting, denormalization. See the visualization of the plan to understand which plan nodes are the main bottlenecks. 

:exclamation: VACUUM ANALYZE needed  Visibility map(s) for the table(s) involved in the query are outdated. For better performance: 1) run VACUUM ANALYZE on them as a one-time solution, 2) perform autovacuum tuning as a long-term permanent solution (tuning "vacuum" part of autovacuum).

Part of #205578 (closed)

Screenshots

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 Giorgenes Gelatti

Merge request reports