Merge branch 'bw-add-index-for-relative-position' into 'master'
Add index for issues on relative position, project, and state for manual sorting See merge request gitlab-org/gitlab-ce!30542
This commit is contained in:
commit
31335ea661
4 changed files with 27 additions and 1 deletions
|
@ -131,7 +131,7 @@ class Issue < ApplicationRecord
|
||||||
when 'due_date' then order_due_date_asc
|
when 'due_date' then order_due_date_asc
|
||||||
when 'due_date_asc' then order_due_date_asc
|
when 'due_date_asc' then order_due_date_asc
|
||||||
when 'due_date_desc' then order_due_date_desc
|
when 'due_date_desc' then order_due_date_desc
|
||||||
when 'relative_position' then order_relative_position_asc
|
when 'relative_position' then order_relative_position_asc.with_order_id_desc
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Add index for issues on relative position, project, and state for manual sorting
|
||||||
|
merge_request: 30542
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -0,0 +1,20 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddIndexToIssuesRelativePosition < ActiveRecord::Migration[5.1]
|
||||||
|
include Gitlab::Database::MigrationHelpers
|
||||||
|
|
||||||
|
# Set this constant to true if this migration requires downtime.
|
||||||
|
DOWNTIME = false
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
INDEX_NAME = 'index_issues_on_project_id_and_state_and_rel_position_and_id'.freeze
|
||||||
|
|
||||||
|
def up
|
||||||
|
add_concurrent_index :issues, [:project_id, :state, :relative_position, :id], order: { id: :desc }, name: INDEX_NAME
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_concurrent_index_by_name :issues, INDEX_NAME
|
||||||
|
end
|
||||||
|
end
|
|
@ -1682,6 +1682,7 @@ ActiveRecord::Schema.define(version: 2019_07_15_114644) do
|
||||||
t.index ["project_id", "created_at", "id", "state"], name: "index_issues_on_project_id_and_created_at_and_id_and_state", using: :btree
|
t.index ["project_id", "created_at", "id", "state"], name: "index_issues_on_project_id_and_created_at_and_id_and_state", using: :btree
|
||||||
t.index ["project_id", "due_date", "id", "state"], name: "idx_issues_on_project_id_and_due_date_and_id_and_state_partial", where: "(due_date IS NOT NULL)", using: :btree
|
t.index ["project_id", "due_date", "id", "state"], name: "idx_issues_on_project_id_and_due_date_and_id_and_state_partial", where: "(due_date IS NOT NULL)", using: :btree
|
||||||
t.index ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree
|
t.index ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree
|
||||||
|
t.index ["project_id", "state", "relative_position", "id"], name: "index_issues_on_project_id_and_state_and_rel_position_and_id", order: { id: :desc }, using: :btree
|
||||||
t.index ["project_id", "updated_at", "id", "state"], name: "index_issues_on_project_id_and_updated_at_and_id_and_state", using: :btree
|
t.index ["project_id", "updated_at", "id", "state"], name: "index_issues_on_project_id_and_updated_at_and_id_and_state", using: :btree
|
||||||
t.index ["relative_position"], name: "index_issues_on_relative_position", using: :btree
|
t.index ["relative_position"], name: "index_issues_on_relative_position", using: :btree
|
||||||
t.index ["state"], name: "index_issues_on_state", using: :btree
|
t.index ["state"], name: "index_issues_on_state", using: :btree
|
||||||
|
|
Loading…
Reference in a new issue