Add index for selecting active agent tokens
What does this MR do and why?
Adds a new index to cluster_agent_tokens
to optimise querying the recently added status
field.
Screenshots or screen recordings
== 20220111023852 IndexClusterAgentTokensOnStatus: migrating ==================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:cluster_agent_tokens, "agent_id, status, last_used_at DESC NULLS LAST", {:name=>"index_cluster_agent_tokens_on_agent_id_status_last_used_at", :algorithm=>:concurrently})
-> 0.0160s
-- execute("SET statement_timeout TO 0")
-> 0.0009s
-- add_index(:cluster_agent_tokens, "agent_id, status, last_used_at DESC NULLS LAST", {:name=>"index_cluster_agent_tokens_on_agent_id_status_last_used_at", :algorithm=>:concurrently})
-> 0.0057s
-- execute("RESET statement_timeout")
-> 0.0007s
== 20220111023852 IndexClusterAgentTokensOnStatus: migrated (0.0257s) =========
== 20220111023852 IndexClusterAgentTokensOnStatus: reverting ==================
-- transaction_open?()
-> 0.0000s
-- indexes(:cluster_agent_tokens)
-> 0.0041s
-- execute("SET statement_timeout TO 0")
-> 0.0007s
-- remove_index(:cluster_agent_tokens, {:algorithm=>:concurrently, :name=>"index_cluster_agent_tokens_on_agent_id_status_last_used_at"})
-> 0.0071s
-- execute("RESET statement_timeout")
-> 0.0008s
== 20220111023852 IndexClusterAgentTokensOnStatus: reverted (0.0151s) =========
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.
Edited by Mayra Cabrera