Skip to content

Resolve "Inverse index on namespaces parent_id, id"

What does this MR do?

Add an index: create index idx_namespaces_and_child_groups on namespaces (id) where parent_id IS NOT NULL

As recommend by !57318 (comment 566770357) in order to walk over the namespaces table.

== 20210506064413 CreateNamespacesIdParentIdInversePartialIndex: migrating ====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:namespaces, :id, {:where=>"parent_id IS NOT NULL", :name=>"index_namespaces_id_parent_id_is_not_null", :algorithm=>:concurrently})
   -> 0.0118s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- add_index(:namespaces, :id, {:where=>"parent_id IS NOT NULL", :name=>"index_namespaces_id_parent_id_is_not_null", :algorithm=>:concurrently})
   -> 0.0038s
-- execute("RESET ALL")
   -> 0.0005s
== 20210506064413 CreateNamespacesIdParentIdInversePartialIndex: migrated (0.0177s)

== 20210506064413 CreateNamespacesIdParentIdInversePartialIndex: reverting ====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:namespaces, :id, {:name=>"index_namespaces_id_parent_id_is_not_null", :algorithm=>:concurrently})
   -> 0.0077s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- remove_index(:namespaces, {:name=>"index_namespaces_id_parent_id_is_not_null", :algorithm=>:concurrently, :column=>:id})
   -> 0.0093s
-- execute("RESET ALL")
   -> 0.0006s
== 20210506064413 CreateNamespacesIdParentIdInversePartialIndex: reverted (0.0191s)

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

Related to #330086 (closed)

Edited by Alex Pooley

Merge request reports