Skip to content

Remove `index_identities_on_provider` DB index

Bogdan Denkovych requested to merge remove-index_identities_on_provider into master

What does this MR do and why?

We added index_identities_on_provider DB index to speed up

DB migrations. Since this index is not used by the application we should remove it.

Related to https://gitlab.com/gitlab-org/security/gitlab/-/merge_requests/3962/diffs#note_1874744321, https://gitlab.com/gitlab-org/gitlab/-/issues/456424

DB migration

bin/rails db:migrate RAILS_ENV=test
main: == [advisory_lock_connection] object_id: 128540, pg_backend_pid: 27934
main: == 20240607105207 RemoveIndexIdentitiesOnProvider: migrating ==================
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0053s
main: -- indexes(:identities)
main:    -> 0.0062s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0010s
main: -- remove_index(:identities, {:algorithm=>:concurrently, :name=>"index_identities_on_provider"})
main:    -> 0.0030s
main: -- execute("RESET statement_timeout")
main:    -> 0.0012s
main: == 20240607105207 RemoveIndexIdentitiesOnProvider: migrated (0.0419s) =========

main: == [advisory_lock_connection] object_id: 128540, pg_backend_pid: 27934
ci: == [advisory_lock_connection] object_id: 128720, pg_backend_pid: 27936
ci: == 20240607105207 RemoveIndexIdentitiesOnProvider: migrating ==================
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0012s
ci: -- indexes(:identities)
ci:    -> 0.0064s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0011s
ci: -- remove_index(:identities, {:algorithm=>:concurrently, :name=>"index_identities_on_provider"})
ci:    -> 0.0023s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0015s
ci: == 20240607105207 RemoveIndexIdentitiesOnProvider: migrated (0.0412s) =========

ci: == [advisory_lock_connection] object_id: 128720, pg_backend_pid: 27936
bin/rails db:migrate:down:main VERSION=20240607105207 RAILS_ENV=test
main: == [advisory_lock_connection] object_id: 117240, pg_backend_pid: 26723
main: == 20240607105207 RemoveIndexIdentitiesOnProvider: reverting ==================
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0031s
main: -- index_exists?(:identities, :provider, {:name=>"index_identities_on_provider", :algorithm=>:concurrently})
main:    -> 0.0033s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0005s
main: -- add_index(:identities, :provider, {:name=>"index_identities_on_provider", :algorithm=>:concurrently})
main:    -> 0.0018s
main: -- execute("RESET statement_timeout")
main:    -> 0.0005s
main: == 20240607105207 RemoveIndexIdentitiesOnProvider: reverted (0.0244s) =========

main: == [advisory_lock_connection] object_id: 117240, pg_backend_pid: 26723
bin/rails db:migrate:down:ci VERSION=20240607105207 RAILS_ENV=test
ci: == [advisory_lock_connection] object_id: 117240, pg_backend_pid: 27103
ci: == 20240607105207 RemoveIndexIdentitiesOnProvider: reverting ==================
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0030s
ci: -- index_exists?(:identities, :provider, {:name=>"index_identities_on_provider", :algorithm=>:concurrently})
ci:    -> 0.0032s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0004s
ci: -- add_index(:identities, :provider, {:name=>"index_identities_on_provider", :algorithm=>:concurrently})
ci:    -> 0.0021s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0005s
ci: == 20240607105207 RemoveIndexIdentitiesOnProvider: reverted (0.0304s) =========

ci: == [advisory_lock_connection] object_id: 117240, pg_backend_pid: 27103

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Bogdan Denkovych

Merge request reports