diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-11-26 17:43:54 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-11-26 17:43:54 +0000 |
commit | 890addcbf3362ffada5fc61daa28b40f06d3812c (patch) | |
tree | 6a17b85fdb73893449e598388649860a5685901c | |
parent | fb6281eab1404e4391edeb5a9b399b7ba948f364 (diff) | |
parent | ad7d1607d04c442a4aa9cae4bc266cdadecb2a54 (diff) | |
download | gitlab-ce-890addcbf3362ffada5fc61daa28b40f06d3812c.tar.gz |
Merge branch '53992-add-events-index-on-project-id-and-created-at' into 'master'
Add events index on project_id and created_at
Closes #53992
See merge request gitlab-org/gitlab-ce!23354
-rw-r--r-- | changelogs/unreleased/53992-add-events-index-on-project-id-and-created-at.yml | 5 | ||||
-rw-r--r-- | db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb | 32 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 39 insertions, 1 deletions
diff --git a/changelogs/unreleased/53992-add-events-index-on-project-id-and-created-at.yml b/changelogs/unreleased/53992-add-events-index-on-project-id-and-created-at.yml new file mode 100644 index 00000000000..a2a3fa00f01 --- /dev/null +++ b/changelogs/unreleased/53992-add-events-index-on-project-id-and-created-at.yml @@ -0,0 +1,5 @@ +--- +title: Add index for events on project_id and created_at +merge_request: 23354 +author: +type: performance diff --git a/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb b/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb new file mode 100644 index 00000000000..7e9c56957d5 --- /dev/null +++ b/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddEventsIndexOnProjectIdAndCreatedAt < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index(*index_arguments) + end + + def down + remove_concurrent_index(*index_arguments) + end + + private + + def index_arguments + [ + :events, + [:project_id, :created_at], + { + name: 'index_events_on_project_id_and_created_at' + } + ] + end +end diff --git a/db/schema.rb b/db/schema.rb index 1fdc417b639..acabd7b442b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20181112103239) do +ActiveRecord::Schema.define(version: 20181126150622) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -867,6 +867,7 @@ ActiveRecord::Schema.define(version: 20181112103239) do t.string "target_type" t.index ["action"], name: "index_events_on_action", using: :btree t.index ["author_id", "project_id"], name: "index_events_on_author_id_and_project_id", using: :btree + t.index ["project_id", "created_at"], name: "index_events_on_project_id_and_created_at", using: :btree t.index ["project_id", "id"], name: "index_events_on_project_id_and_id", using: :btree t.index ["target_type", "target_id"], name: "index_events_on_target_type_and_target_id", using: :btree end |