diff --git a/db/post_migrate/20210802112233_add_index_issues_on_project_id_and_state_id_and_created_at_and_id.rb b/db/post_migrate/20210802112233_add_index_issues_on_project_id_and_state_id_and_created_at_and_id.rb new file mode 100644 index 0000000000000000000000000000000000000000..318d9e8a218b3cc9340b212397545ed3649c924e --- /dev/null +++ b/db/post_migrate/20210802112233_add_index_issues_on_project_id_and_state_id_and_created_at_and_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexIssuesOnProjectIdAndStateIdAndCreatedAtAndId < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_issues_on_project_id_and_state_id_and_created_at_and_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :issues, [:project_id, :state_id, :created_at, :id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :issues, INDEX_NAME + end +end diff --git a/db/schema_migrations/20210802112233 b/db/schema_migrations/20210802112233 new file mode 100644 index 0000000000000000000000000000000000000000..68626f9398b081f664f7971c49af26bba13a4a72 --- /dev/null +++ b/db/schema_migrations/20210802112233 @@ -0,0 +1 @@ +1b55c50a9ba085ae7a0552da4985755c67eafb74e76b06590179803b4b215f81 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index ad92c14adec209512f48c3b5102127fdbd58d894..953b37d7a9afb6ad15f71c648f0136d2fc8b9d1c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -24100,6 +24100,8 @@ CREATE UNIQUE INDEX index_issues_on_project_id_and_external_key ON issues USING CREATE UNIQUE INDEX index_issues_on_project_id_and_iid ON issues USING btree (project_id, iid); +CREATE INDEX index_issues_on_project_id_and_state_id_and_created_at_and_id ON issues USING btree (project_id, state_id, created_at, id); + CREATE INDEX index_issues_on_project_id_and_upvotes_count ON issues USING btree (project_id, upvotes_count); 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);