Skip to content

Perform exact comparison when filtering pipelines by name

Reuben Pereira requested to merge rp/pipeline-name-exact-compare into master

What does this MR do and why?

Describe in detail what your merge request does and why.

We had previously added an index on pipeline_id, lower(name) text_pattern_ops since we were planning to perform case insensitive comparisons with the name column.

However, in #376097, it was decided to perform a regular (case sensitive) comparison.

This MR:

  • Removes the index on pipeline_id, lower(name) and adds one on pipeline_id, name instead.
  • Changes PipelinesFinder to perform a regular (case sensitive) comparison when searching for pipelines by name. Note that this functionality is not used anywhere currently.

Migration output:

main: == 20230203122609 ChangePipelineNameIndex: migrating ==========================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0818s
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.0113s
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.0134s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0020s
main: -- indexes(:ci_pipeline_metadata)
main:    -> 0.0075s
main: -- remove_index(:ci_pipeline_metadata, {:algorithm=>:concurrently, :name=>"index_pipeline_metadata_on_pipeline_id_name_lower_text_pattern"})
main:    -> 0.0046s
main: == 20230121173521 ChangePipelineNameIndex: migrated (0.1648s) =================

Revert output:

main: == 20230203122609 ChangePipelineNameIndex: reverting ==========================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0736s
main: -- index_exists?(:ci_pipeline_metadata, "pipeline_id, lower(name) text_pattern_ops", {:name=>"index_pipeline_metadata_on_pipeline_id_name_lower_text_pattern", :algorithm=>:concurrently})
main:    -> 0.0111s
main: -- add_index(:ci_pipeline_metadata, "pipeline_id, lower(name) text_pattern_ops", {:name=>"index_pipeline_metadata_on_pipeline_id_name_lower_text_pattern", :algorithm=>:concurrently})
main:    -> 0.0073s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0016s
main: -- indexes(:ci_pipeline_metadata)
main:    -> 0.0071s
main: -- remove_index(:ci_pipeline_metadata, {:algorithm=>:concurrently, :name=>"index_pipeline_metadata_on_pipeline_id_name_text_pattern"})
main:    -> 0.0041s
main: == 20230121173521 ChangePipelineNameIndex: reverted (0.1447s) =================

Related issue: #376097

Screenshots or screen recordings

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

How to set up and validate locally

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

There is no way to access this functionality via the UI currently.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Reuben Pereira

Merge request reports

Loading