Index deployments table for DeploymentsFinder's query performance
What does this MR do and why?
Create index_deployments_on_project_id_and_environment_id_and_status_and_finished_at
to resolve #357648 (closed)
We also checked index_deployments_for_visible_scope
implemented in !83498 (merged) but observed it is not useful.
How to set up and validate locally
rails db:migrate:up VERSION=20220404140813
== 20220404140813 PrepareIndexProjectIdEnvironmentIdStatusFinishedAtOnDeployments: migrating
-- transaction_open?()
-> 0.0000s
-- index_exists?(:deployments, [:project_id, :environment_id, :status, :finished_at], {:name=>"index_deployments_on_project_environment_status_and_finished_at", :algorithm=>:concurrently})
-> 0.0104s
-- execute("SET statement_timeout TO 0")
-> 0.0005s
-- add_index(:deployments, [:project_id, :environment_id, :status, :finished_at], {:name=>"index_deployments_on_project_environment_status_and_finished_at", :algorithm=>:concurrently})
-> 0.0077s
-- execute("RESET statement_timeout")
-> 0.0006s
== 20220404140813 PrepareIndexProjectIdEnvironmentIdStatusFinishedAtOnDeployments: migrated (0.0274s)
rails db:migrate:down VERSION=20220404140813
== 20220404140813 PrepareIndexProjectIdEnvironmentIdStatusFinishedAtOnDeployments: reverting
-- transaction_open?()
-> 0.0000s
-- indexes(:deployments)
-> 0.0095s
-- execute("SET statement_timeout TO 0")
-> 0.0005s
-- remove_index(:deployments, {:algorithm=>:concurrently, :name=>"index_deployments_on_project_environment_status_and_finished_at"})
-> 0.0036s
-- execute("RESET statement_timeout")
-> 0.0005s
== 20220404140813 PrepareIndexProjectIdEnvironmentIdStatusFinishedAtOnDeployments: reverted (0.0207s)
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 #357648 (closed)
Edited by Bala Kumar