Skip to content

Adds project_path sorting to group package api

What does this MR do?

Adds projet path sorting to group packages API entry point.

New query and plans:


explain SELECT "packages_packages".* FROM "packages_packages" INNER JOIN "projects" ON "projects"."id" = "packages_packages"."project_id" WHERE "packages_packages"."project_id" IN (278964, 13831684) ORDER BY projects.path DESC, id DESC LIMIT 20 OFFSET 0

/* no execution */
Limit  (cost=76.94..76.97 rows=12 width=93)
  ->  Sort  (cost=76.94..76.97 rows=12 width=93)
        Sort Key: projects.path DESC, packages_packages.id DESC
        ->  Nested Loop  (cost=0.73..76.73 rows=12 width=93)
              ->  Index Scan using index_packages_packages_on_project_id_and_package_type on packages_packages  (cost=0.29..23.18 rows=12 width=80)
                    Index Cond: (project_id = ANY ('{278964,13831684}'::integer[]))
              ->  Index Scan using projects_pkey on projects  (cost=0.43..4.45 rows=1 width=17)
                    Index Cond: (id = packages_packages.project_id)


/* with execution */
 Limit  (cost=76.94..76.97 rows=12 width=93) (actual time=1.033..1.034 rows=0 loops=1)
   Buffers: shared hit=9 read=1
   I/O Timings: read=0.941
   ->  Sort  (cost=76.94..76.97 rows=12 width=93) (actual time=1.031..1.031 rows=0 loops=1)
         Sort Key: projects.path DESC, packages_packages.id DESC
         Sort Method: quicksort  Memory: 25kB
         Buffers: shared hit=9 read=1
         I/O Timings: read=0.941
         ->  Nested Loop  (cost=0.73..76.73 rows=12 width=93) (actual time=0.967..0.967 rows=0 loops=1)
               Buffers: shared hit=3 read=1
               I/O Timings: read=0.941
               ->  Index Scan using index_packages_packages_on_project_id_and_package_type on public.packages_packages  (cost=0.29..23.18 rows=12 width=80) (actual time=0.964..0.964 rows=0 loops=1)
                     Index Cond: (packages_packages.project_id = ANY ('{278964,13831684}'::integer[]))
                     Buffers: shared hit=3 read=1
                     I/O Timings: read=0.941
               ->  Index Scan using projects_pkey on public.projects  (cost=0.43..4.45 rows=1 width=17) (actual time=0.000..0.000 rows=0 loops=0)
                     Index Cond: (projects.id = packages_packages.project_id)

Summary

Time: 2.194 ms
  - planning: 1.046 ms
  - execution: 1.148 ms
    - I/O read: 0.941 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 9 (~72.00 KiB) from the buffer pool
  - reads: 1 (~8.00 KiB) from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

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

Closes #201897 (closed)

Edited by Mayra Cabrera

Merge request reports