Drop index_deployments_on_cluster_id_and_status async-ly
What does this MR do and why?
This is part of an epic to optimize the deployments table by removing unused indexes: &10185
This MR is an asynchronous removal migration for index_deployments_on_cluster_id_and_status
.
This index has a usage rate of 0.00038580343295489567
from the past 60 days. (see Thanos query). However, there is nowhere in the code base that performs a query using the combination of cluster_id
and status
(see comment), and as shown in the API documentations (REST & GraphQL), the cluster_id
field is not used in queries. So this index should be safe to drop.
The definition of this index is:
CREATE INDEX index_deployments_on_cluster_id_and_status ON deployments USING btree (cluster_id, status);
The sync index removal will be done in a follow-up MR, as part of #402505 (closed).
Screenshots or screen recordings
Migration output
main: == [advisory_lock_connection] object_id: 227220, pg_backend_pid: 60616
main: == 20231002031617 PrepareRemovalIndexDeploymentsOnClusterIdAndStatus: migrating
main: -- index_exists?(:deployments, [:cluster_id, :status], {:name=>"index_deployments_on_cluster_id_and_status"})
main: -> 0.0768s
main: -- quote_column_name("index_deployments_on_cluster_id_and_status")
main: -> 0.0000s
main: == 20231002031617 PrepareRemovalIndexDeploymentsOnClusterIdAndStatus: migrated (0.1072s)
main: == [advisory_lock_connection] object_id: 227220, pg_backend_pid: 60616
Testing the async removal
Following this guide:
After running bundle exec rails db:migrate
:
After running bundle exec rails gitlab:db:reindex
:
gitlabhq_development=# \d index_deployments_on_cluster_id_and_status
Did not find any relation named "index_deployments_on_cluster_id_and_status".
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #402505 (closed)