Commit 20686f75 authored by Sean McGivern's avatar Sean McGivern Committed by Andreas Brandl

Remove index on issues.relative_position

This index is only on a single column, `relative_position`. However,
when we query issues by anything other than ID, we pretty much always do
that with a filter on `project_id`. (The exception is an admin user
viewing a dashboard, which is a rare case, and there aren't
instance-level boards anyway.)

We already have an index that's perfect for filtering by `project_id`
and ordering by `relative_position`, because it's on these columns:

    (project_id, relative_position, state_id, id DESC)

But sometimes the planner won't use it because of this index, which can
lead to poor query performance.
parent b18cdc7a
---
title: Remove index on issues.relative_position
merge_request: 43991
author:
type: performance
# frozen_string_literal: true
class RemoveIndexOnIssuesRelativePosition < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
INDEX_NAME = 'index_issues_on_relative_position'
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index_by_name(:issues, INDEX_NAME)
end
def down
add_concurrent_index(:issues, :relative_position, name: INDEX_NAME)
end
end
f3f9dd503d2c2695d5cd32ea87ff11e45832b1650df3186c7f71c984fc59ad24
\ No newline at end of file
......@@ -20501,8 +20501,6 @@ CREATE UNIQUE INDEX index_issues_on_project_id_and_iid ON issues USING btree (pr
CREATE INDEX index_issues_on_promoted_to_epic_id ON issues USING btree (promoted_to_epic_id) WHERE (promoted_to_epic_id IS NOT NULL);
CREATE INDEX index_issues_on_relative_position ON issues USING btree (relative_position);
CREATE INDEX index_issues_on_sprint_id ON issues USING btree (sprint_id);
CREATE INDEX index_issues_on_title_trigram ON issues USING gin (title gin_trgm_ops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment