Skip to content

Add temporary partial index on services table

What does this MR do?

This change was requested as a part of review !24684 (comment 299612448)

In order to improve performance of upcoming data migration, we need to add partial index on services table

Oh and going one step further, if we have an index on services (project_id, type, id) - that should yield an index-only scan for the anti-join (since the filters and the id is all we need in the query from services).

And yet another improvement (sorry): Let's make it partial for services (project_id, id) WHERE type = 'PrometheusService' since that is all we're interested in really. This is how it looks like with the partial index:

         ->  Index Only Scan using services_project_id_id_idx on services  (cost=0.29..9.53 rows=87 width=8) (never executed)
               Index Cond: ((project_id >= 1) AND (project_id <= 10000))
               Heap Fetches: 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
Edited by 🤖 GitLab Bot 🤖

Merge request reports