Skip to content

Resolve "Remove 2 unnecessary indexes related to traversal ids"

Problem to solve

In an MR, @ahegyi suggested creating a follow-up issue to remove 2 indexes.

This MR will remove these 2 temporary database indexes:

  1. tmp_index_namespaces_empty_traversal_ids_with_root_namespaces
  2. tmp_index_namespaces_empty_traversal_ids_with_child_namespaces
$ rails db:migrate:up:main VERSION=20220510003916
== 20220510003916 RemoveTmpEmptyTraversalIdsRootNamespaceIndex: migrating =====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:namespaces, :id, {:name=>"tmp_index_namespaces_empty_traversal_ids_with_root_namespaces", :algorithm=>:concurrently})
   -> 0.0542s
-- execute("SET statement_timeout TO 0")
   -> 0.0008s
-- remove_index(:namespaces, {:name=>"tmp_index_namespaces_empty_traversal_ids_with_root_namespaces", :algorithm=>:concurrently, :column=>:id})
   -> 0.0328s
-- execute("RESET statement_timeout")
   -> 0.0009s
== 20220510003916 RemoveTmpEmptyTraversalIdsRootNamespaceIndex: migrated (0.1051s)

$ rails db:migrate:down:main VERSION=20220510003916                                                                                                                                  == 20220510003916 RemoveTmpEmptyTraversalIdsRootNamespaceIndex: reverting =====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:namespaces, :id, {:where=>"parent_id IS NULL AND traversal_ids = '{}'", :name=>"tmp_index_namespaces_empty_traversal_ids_with_root_namespaces", :algorithm=>:concurrently})
   -> 0.0255s
-- execute("SET statement_timeout TO 0")
   -> 0.0008s
-- add_index(:namespaces, :id, {:where=>"parent_id IS NULL AND traversal_ids = '{}'", :name=>"tmp_index_namespaces_empty_traversal_ids_with_root_namespaces", :algorithm=>:concurrently})
   -> 0.0073s
-- execute("RESET statement_timeout")
   -> 0.0008s
== 20220510003916 RemoveTmpEmptyTraversalIdsRootNamespaceIndex: reverted (0.0498s)
$ rails db:migrate:up:main VERSION=20220510004501
== 20220510004501 RemoveTmpEmptyTraversalIdsChildNamespaceIndex: migrating ====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:namespaces, :id, {:name=>"tmp_index_namespaces_empty_traversal_ids_with_child_namespaces", :algorithm=>:concurrently})
   -> 0.0270s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- remove_index(:namespaces, {:name=>"tmp_index_namespaces_empty_traversal_ids_with_child_namespaces", :algorithm=>:concurrently, :column=>:id})
   -> 0.0232s
-- execute("RESET statement_timeout")
   -> 0.0008s
== 20220510004501 RemoveTmpEmptyTraversalIdsChildNamespaceIndex: migrated (0.0662s)

$ rails db:migrate:down:main VERSION=20220510004501                                                                                                                                  == 20220510004501 RemoveTmpEmptyTraversalIdsChildNamespaceIndex: reverting ====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:namespaces, :id, {:where=>"parent_id IS NOT NULL AND traversal_ids = '{}'", :name=>"tmp_index_namespaces_empty_traversal_ids_with_child_namespaces", :algorithm=>:concurrently})
   -> 0.0265s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- add_index(:namespaces, :id, {:where=>"parent_id IS NOT NULL AND traversal_ids = '{}'", :name=>"tmp_index_namespaces_empty_traversal_ids_with_child_namespaces", :algorithm=>:concurrently})
   -> 0.0062s
-- execute("RESET statement_timeout")
   -> 0.0007s
== 20220510004501 RemoveTmpEmptyTraversalIdsChildNamespaceIndex: reverted (0.0485s)

Closes #333365 (closed)

Edited by Alex Pooley

Merge request reports

Loading