Remove priority sort from board list issues
What does this MR do and why?
Sorts issues on an issue board list by relative position and ID only instead of relative position, label priority, and ID.
Priority sort was added in gitlab-foss!9939 (merged) in the early days of issue boards and I believe we weren't setting positions for all the issues yet. Right now, when an issue is created, the IssuePlacementWorker
sets the position to be after the max position.
Also, when a board list is requested, we synchronously set all nil positions so that we don't return issues with null positions.
So priority sort is not needed because it would be very rare where we have collisions on relative_position
. Only on invalid data on the database. And the secondary sort on ID should take care of that.
This also fixes a minor bug on the secondary sort so that we sort by id ASC
and not id DESC
. We move issues to the end as they are created so higher IDs should be at the end. This is similar to what the IssuePlacementWorker
does.
-
Old query: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/6574/commands/22940
Time: 107.432 ms - planning: 23.685 ms - execution: 83.747 ms - I/O read: 0.000 ms - I/O write: 0.000 ms Shared buffers: - hits: 72324 (~565.00 MiB) from the buffer pool - reads: 0 from the OS file cache, including disk I/O - dirtied: 0 - writes: 0
-
New query: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/6574/commands/22942
Time: 49.483 ms - planning: 7.712 ms - execution: 41.771 ms - I/O read: 0.000 ms - I/O write: 0.000 ms Shared buffers: - hits: 22217 (~173.60 MiB) from the buffer pool - reads: 0 from the OS file cache, including disk I/O - dirtied: 0 - writes: 0
Migration output
== 20210927153807 UpdateIssuesRelativePositionIndexes: migrating ==============
-- transaction_open?()
-> 0.0000s
-- index_exists?(:issues, [:project_id, :relative_position, :id, :state_id], {:name=>"idx_issues_on_project_id_and_rel_position_and_id_and_state_id", :algorithm=>:concurrently})
-> 0.0142s
-- add_index(:issues, [:project_id, :relative_position, :id, :state_id], {:name=>"idx_issues_on_project_id_and_rel_position_and_id_and_state_id", :algorithm=>:concurrently})
-> 0.0295s
-- transaction_open?()
-> 0.0000s
-- indexes(:issues)
-> 0.0124s
-- remove_index(:issues, {:algorithm=>:concurrently, :name=>"idx_issues_on_project_id_and_rel_asc_and_id"})
-> 0.0070s
-- transaction_open?()
-> 0.0000s
-- indexes(:issues)
-> 0.0118s
-- remove_index(:issues, {:algorithm=>:concurrently, :name=>"idx_issues_on_project_id_and_rel_position_and_state_id_and_id"})
-> 0.0064s
== 20210927153807 UpdateIssuesRelativePositionIndexes: migrated (0.0884s) =====
== 20210927153807 UpdateIssuesRelativePositionIndexes: reverting ==============
-- transaction_open?()
-> 0.0000s
-- index_exists?(:issues, [:project_id, :relative_position, :state_id, :id], {:order=>{:id=>:desc}, :name=>"idx_issues_on_project_id_and_rel_position_and_state_id_and_id", :algorithm=>:concurrently})
-> 0.0123s
-- add_index(:issues, [:project_id, :relative_position, :state_id, :id], {:order=>{:id=>:desc}, :name=>"idx_issues_on_project_id_and_rel_position_and_state_id_and_id", :algorithm=>:concurrently})
-> 0.0092s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:issues, [:project_id, :relative_position, :id], {:name=>"idx_issues_on_project_id_and_rel_asc_and_id", :algorithm=>:concurrently})
-> 0.0117s
-- add_index(:issues, [:project_id, :relative_position, :id], {:name=>"idx_issues_on_project_id_and_rel_asc_and_id", :algorithm=>:concurrently})
-> 0.0079s
-- transaction_open?()
-> 0.0000s
-- indexes(:issues)
-> 0.0123s
-- remove_index(:issues, {:algorithm=>:concurrently, :name=>"idx_issues_on_project_id_and_rel_position_and_id_and_state_id"})
-> 0.0043s
== 20210927153807 UpdateIssuesRelativePositionIndexes: reverted (0.0648s) =====
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.