Skip to content

Remove unused index on ci_pipeline_metadata

Reuben Pereira requested to merge rp/remove-old-pipeline-name-index into master

What does this MR do and why?

Remove unused index on ci_pipeline_metadata.

Since an index on [name, pipeline_id] has been introduced (in !140607 (merged)), we can remove the old index on [pipeline_id, name].

The new index has already been successfully created on gitlab.com. Verified on database-lab: https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/25293/commands/80515.

pipeline_id is the table's primary key, so there is already an index on it. See all indexes of the table: https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/25293/commands/80523.

main: == [advisory_lock_connection] object_id: 183000, pg_backend_pid: 2210
main: == 20240212120012 RemoveIndexOnPipelineMetadata: migrating ====================
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.1414s
main: -- indexes(:ci_pipeline_metadata)
main:    -> 0.0100s
main: -- remove_index(:ci_pipeline_metadata, {:algorithm=>:concurrently, :name=>"index_pipeline_metadata_on_pipeline_id_name_text_pattern"})
main:    -> 0.0069s
main: == 20240212120012 RemoveIndexOnPipelineMetadata: migrated (0.2011s) ===========

main: == [advisory_lock_connection] object_id: 183000, pg_backend_pid: 2210
ci: == [advisory_lock_connection] object_id: 183220, pg_backend_pid: 2212
ci: == 20240212120012 RemoveIndexOnPipelineMetadata: migrating ====================
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0011s
ci: -- indexes(:ci_pipeline_metadata)
ci:    -> 0.0086s
ci: -- remove_index(:ci_pipeline_metadata, {:algorithm=>:concurrently, :name=>"index_pipeline_metadata_on_pipeline_id_name_text_pattern"})
ci:    -> 0.0049s
ci: == 20240212120012 RemoveIndexOnPipelineMetadata: migrated (0.0409s) ===========

Down migration:

main: == [advisory_lock_connection] object_id: 182700, pg_backend_pid: 6208
main: == 20240212120012 RemoveIndexOnPipelineMetadata: reverting ====================
main: -- index_name_exists?(:ci_pipeline_metadata, "index_pipeline_metadata_on_pipeline_id_name_text_pattern")
main:    -> 0.0451s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0012s
main: -- index_exists?(:ci_pipeline_metadata, "pipeline_id, name text_pattern_ops", {:name=>"index_pipeline_metadata_on_pipeline_id_name_text_pattern", :algorithm=>:concurrently})
main:    -> 0.0053s
main: -- add_index(:ci_pipeline_metadata, "pipeline_id, name text_pattern_ops", {:name=>"index_pipeline_metadata_on_pipeline_id_name_text_pattern", :algorithm=>:concurrently})
main:    -> 0.0072s
main: == 20240212120012 RemoveIndexOnPipelineMetadata: reverted (0.1100s) ===========

ci: == [advisory_lock_connection] object_id: 182640, pg_backend_pid: 6226
ci: == 20240212120012 RemoveIndexOnPipelineMetadata: reverting ====================
ci: -- index_name_exists?(:ci_pipeline_metadata, "index_pipeline_metadata_on_pipeline_id_name_text_pattern")
ci:    -> 0.0340s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0011s
ci: -- index_exists?(:ci_pipeline_metadata, "pipeline_id, name text_pattern_ops", {:name=>"index_pipeline_metadata_on_pipeline_id_name_text_pattern", :algorithm=>:concurrently})
ci:    -> 0.0068s
ci: -- add_index(:ci_pipeline_metadata, "pipeline_id, name text_pattern_ops", {:name=>"index_pipeline_metadata_on_pipeline_id_name_text_pattern", :algorithm=>:concurrently})
ci:    -> 0.0089s
ci: == 20240212120012 RemoveIndexOnPipelineMetadata: reverted (0.0817s) ===========

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 Reuben Pereira

Merge request reports