Skip to content

Update MR index to include id

Robert May requested to merge update-index-used-in-mr-api into master

What does this MR do?

Adjusts an index to improve performance on the merge requests API.

Related #209780 (closed)

Migrating

❯ rake db:migrate                             
== 20200914104642 ModifyMergeRequestApiIndex: migrating =======================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:merge_requests, [:target_project_id, :created_at, :id], {:algorithm=>:concurrently})
   -> 0.0054s
-- add_index(:merge_requests, [:target_project_id, :created_at, :id], {:algorithm=>:concurrently})
   -> 0.0138s
== 20200914104642 ModifyMergeRequestApiIndex: migrated (0.0195s) ==============

== 20200914105202 RemoveOldMergeRequestApiIndex: migrating ====================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:merge_requests, [:target_project_id, :created_at], {:algorithm=>:concurrently})
   -> 0.0214s
-- remove_index(:merge_requests, {:algorithm=>:concurrently, :column=>[:target_project_id, :created_at]})
   -> 0.0244s
== 20200914105202 RemoveOldMergeRequestApiIndex: migrated (0.0466s) ===========

Rolling back

❯ rake db:rollback STEP=2                
== 20200914105202 RemoveOldMergeRequestApiIndex: reverting ====================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:merge_requests, [:target_project_id, :created_at], {:algorithm=>:concurrently})
   -> 0.0057s
-- add_index(:merge_requests, [:target_project_id, :created_at], {:algorithm=>:concurrently})
   -> 0.0055s
== 20200914105202 RemoveOldMergeRequestApiIndex: reverted (0.0114s) ===========

== 20200914104642 ModifyMergeRequestApiIndex: reverting =======================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:merge_requests, [:target_project_id, :created_at, :id], {:algorithm=>:concurrently})
   -> 0.0050s
-- remove_index(:merge_requests, {:algorithm=>:concurrently, :column=>[:target_project_id, :created_at, :id]})
   -> 0.0052s
== 20200914104642 ModifyMergeRequestApiIndex: reverted (0.0104s) ==============

Execution time, new index

exec CREATE INDEX CONCURRENTLY index_merge_requests_on_target_project_id_and_created_at_and_id ON public.merge_requests USING btree (target_project_id, created_at, id);

Session: joe-btfl0o8350j13v069020The query has been executed. Duration: 15.024 min

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Robert May

Merge request reports