Add index for PAT filters
What does this MR do and why?
This is a split MR. The original is located here.
The second part is here.
In the original MR you want to filter Personal Access Tokens (PAT) by certain properties. This MR adds indexes to make the filtering performant.
DB Review
Queries
Filter | Query |
---|---|
created_at & id | https://explain.depesz.com/s/d2PQ |
Migrations up
> rails db:migrate
rails db:migrate
main: == 20220729073603 IndexPersonalAccessTokensOnIdAndCreatedAt: migrating ========
main: -- transaction_open?()
main: -> 0.0000s
main: -- index_exists?(:personal_access_tokens, [:id, :created_at], {:name=>"index_personal_access_tokens_on_id_and_created_at", :algorithm=>:concurrently})
main: -> 0.0100s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0005s
main: -- add_index(:personal_access_tokens, [:id, :created_at], {:name=>"index_personal_access_tokens_on_id_and_created_at", :algorithm=>:concurrently})
main: -> 0.0027s
main: -- execute("RESET statement_timeout")
main: -> 0.0005s
main: == 20220729073603 IndexPersonalAccessTokensOnIdAndCreatedAt: migrated (0.0244s)
Migration down
> rails db:migrate:down:main VERSION=20220729073603
main: == 20220729073603 IndexPersonalAccessTokensOnIdAndCreatedAt: reverting ========
main: -- transaction_open?()
main: -> 0.0000s
main: -- indexes(:personal_access_tokens)
main: -> 0.0115s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0005s
main: -- remove_index(:personal_access_tokens, {:algorithm=>:concurrently, :name=>"index_personal_access_tokens_on_id_and_created_at"})
main: -> 0.0036s
main: -- execute("RESET statement_timeout")
main: -> 0.0007s
main: == 20220729073603 IndexPersonalAccessTokensOnIdAndCreatedAt: reverted (0.0283s)
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 Andreas Deicha