Skip to content

Remove redundant indexes - Optimize team

Adam Hegyi requested to merge 428547-remove-redundant-indexes-optimize-team into master

What does this MR do and why?

This change removes 2 redundant database indexes:

  • index_merge_request_metrics_on_target_project_id
  • index_analytics_ca_group_stages_on_group_id

Database

Up:

main: == 20231024124856 RemoveRedundantGroupStagesIndex: migrating ============
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0137s
main: -- indexes(:analytics_cycle_analytics_group_stages)
main:    -> 0.0040s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- remove_index(:analytics_cycle_analytics_group_stages, {:algorithm=>:concurrently, :name=>"index_analytics_ca_group_stages_on_group_id"})
main:    -> 0.0091s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20231024124856 RemoveRedundantGroupStagesIndex: migrated (0.0377s) ===

main: == [advisory_lock_connection] object_id: 179960, pg_backend_pid: 121803
ci: == [advisory_lock_connection] object_id: 180180, pg_backend_pid: 121805
ci: == 20231024124856 RemoveRedundantGroupStagesIndex: migrating ============
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0006s
ci: -- indexes(:analytics_cycle_analytics_group_stages)
ci:    -> 0.0034s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0001s
ci: -- remove_index(:analytics_cycle_analytics_group_stages, {:algorithm=>:concurrently, :name=>"index_analytics_ca_group_stages_on_group_id"})
ci:    -> 0.0012s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0002s
ci: == 20231024124856 RemoveRemoveRedundantGroupStagesIndex: migrated (0.0180s) ===

main: == [advisory_lock_connection] object_id: 179960, pg_backend_pid: 123110
main: == 20231024125551 RedundantMrMetricsIndexOnTargetProjectId: migrating ===
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0151s
main: -- indexes(:merge_request_metrics)
main:    -> 0.0052s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- remove_index(:merge_request_metrics, {:algorithm=>:concurrently, :name=>"index_merge_request_metrics_on_target_project_id"})
main:    -> 0.0008s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20231024125551 RemoveRedundantMrMetricsIndexOnTargetProjectId: migrated (0.0313s)

main: == [advisory_lock_connection] object_id: 179960, pg_backend_pid: 123110
ci: == [advisory_lock_connection] object_id: 180180, pg_backend_pid: 123112
ci: == 20231024125551 RemoveRedundantMrMetricsIndexOnTargetProjectId: migrating ===
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0007s
ci: -- indexes(:merge_request_metrics)
ci:    -> 0.0049s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0002s
ci: -- remove_index(:merge_request_metrics, {:algorithm=>:concurrently, :name=>"index_merge_request_metrics_on_target_project_id"})
ci:    -> 0.0012s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0001s
ci: == 20231024125551 RemoveRedundantMrMetricsIndexOnTargetProjectId: migrated (0.0202s)

Down:

main: == 20231024125551 RemoveRedundantMrMetricsIndexOnTargetProjectId: reverting ===
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0152s
main: -- index_exists?(:merge_request_metrics, :target_project_id, {:name=>"index_merge_request_metrics_on_target_project_id", :algorithm=>:concurrently})
main:    -> 0.0048s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0001s
main: -- add_index(:merge_request_metrics, :target_project_id, {:name=>"index_merge_request_metrics_on_target_project_id", :algorithm=>:concurrently})
main:    -> 0.0020s
main: -- execute("RESET statement_timeout")
main:    -> 0.0004s
main: == 20231024125551 RemoveRedundantMrMetricsIndexOnTargetProjectId: reverted (0.0327s)


ci: == 20231024125551 RemoveRedundantMrMetricsIndexOnTargetProjectId: reverting ===
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0138s
ci: -- index_exists?(:merge_request_metrics, :target_project_id, {:name=>"index_merge_request_metrics_on_target_project_id", :algorithm=>:concurrently})
ci:    -> 0.0056s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0003s
ci: -- add_index(:merge_request_metrics, :target_project_id, {:name=>"index_merge_request_metrics_on_target_project_id", :algorithm=>:concurrently})
ci:    -> 0.0099s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0002s
ci: == 20231024125551 RemoveRedundantMrMetricsIndexOnTargetProjectId: reverted (0.0468s)

main: == 20231024124856 RemoveRedundantGroupStagesIndex: reverting ==================
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0135s
main: -- index_exists?(:analytics_cycle_analytics_group_stages, :group_id, {:name=>"index_analytics_ca_group_stages_on_group_id", :algorithm=>:concurrently})
main:    -> 0.0037s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- add_index(:analytics_cycle_analytics_group_stages, :group_id, {:name=>"index_analytics_ca_group_stages_on_group_id", :algorithm=>:concurrently})
main:    -> 0.0014s
main: -- execute("RESET statement_timeout")
main:    -> 0.0001s
main: == 20231024124856 RemoveRedundantGroupStagesIndex: reverted (0.0281s) =========


ci: == 20231024124856 RemoveRedundantGroupStagesIndex: reverting ==================
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0136s
ci: -- index_exists?(:analytics_cycle_analytics_group_stages, :group_id, {:name=>"index_analytics_ca_group_stages_on_group_id", :algorithm=>:concurrently})
ci:    -> 0.0046s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0003s
ci: -- add_index(:analytics_cycle_analytics_group_stages, :group_id, {:name=>"index_analytics_ca_group_stages_on_group_id", :algorithm=>:concurrently})
ci:    -> 0.0097s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0003s
ci: == 20231024124856 RemoveRedundantGroupStagesIndex: reverted (0.0441s) =========

MR acceptance checklist

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

Related to #428547 (closed)

Edited by Adam Hegyi

Merge request reports

Loading