Skip to content

Optimise deployments table by removing an unused index

What does this MR do and why?

This change is part of an epic to optimise the deployments table: &10185

This will drop the partial_index_deployments_for_project_id_and_tag index concurrently. It has a usage rate of 0 according to Thanos

The corresponding async-removal MR is here: !119270 (merged). I have confirmed that this index is no longer in gprd.

Issue: #402516 (closed)

Screenshots or screen recordings

DB Migration output:

$ bundle exec rails db:migrate

main: == [advisory_lock_connection] object_id: 275520, pg_backend_pid: 25555
main: == 20230502014227 DropPartialIndexDeploymentsForProjectIdAndTag: migrating ====
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.1276s
main: -- indexes(:deployments)
main:    -> 0.0136s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- remove_index(:deployments, {:algorithm=>:concurrently, :name=>"partial_index_deployments_for_project_id_and_tag"})
main:    -> 0.0039s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20230502014227 DropPartialIndexDeploymentsForProjectIdAndTag: migrated (0.1717s) 

main: == [advisory_lock_connection] object_id: 275520, pg_backend_pid: 25555
ci: == [advisory_lock_connection] object_id: 275740, pg_backend_pid: 25558
ci: == 20230502014227 DropPartialIndexDeploymentsForProjectIdAndTag: migrating ====
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0009s
ci: -- indexes(:deployments)
ci:    -> 0.0122s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0004s
ci: -- remove_index(:deployments, {:algorithm=>:concurrently, :name=>"partial_index_deployments_for_project_id_and_tag"})
ci:    -> 0.0041s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0004s
ci: == 20230502014227 DropPartialIndexDeploymentsForProjectIdAndTag: migrated (0.0358s) 

ci: == [advisory_lock_connection] object_id: 275740, pg_backend_pid: 25558

How to set up and validate locally

N/A

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 Pam Artiaga

Merge request reports

Loading