diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-03-20 19:24:40 +0100 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-03-21 13:41:24 +0100 |
commit | 58a99463b6ee8f643541b42e61be15237ff35a03 (patch) | |
tree | fe07d30fcb4ce9a54480bd065dfca08555cd012e | |
parent | aa2a97b545243f528f60fe74ed1c0374b920f97f (diff) | |
download | gitlab-ce-58a99463b6ee8f643541b42e61be15237ff35a03.tar.gz |
Add indexes for user activity queries.
Closes #44446.
-rw-r--r-- | changelogs/unreleased/ab-44446-add-indexes-for-user-activity-queries.yml | 5 | ||||
-rw-r--r-- | db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 4 |
3 files changed, 25 insertions, 1 deletions
diff --git a/changelogs/unreleased/ab-44446-add-indexes-for-user-activity-queries.yml b/changelogs/unreleased/ab-44446-add-indexes-for-user-activity-queries.yml new file mode 100644 index 00000000000..0f89c06fcee --- /dev/null +++ b/changelogs/unreleased/ab-44446-add-indexes-for-user-activity-queries.yml @@ -0,0 +1,5 @@ +--- +title: Add indexes for user activity queries. +merge_request: 17890 +author: +type: performance diff --git a/db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb b/db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb new file mode 100644 index 00000000000..3232d5fe1e5 --- /dev/null +++ b/db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb @@ -0,0 +1,17 @@ +class AddIndexesForUserActivityQueries < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :events, [:project_id, :author_id] + add_concurrent_index :user_interacted_projects, :user_id + end + + def down + remove_concurrent_index :events, [:project_id, :author_id] + remove_concurrent_index :user_interacted_projects, :user_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 3ff1a8754e2..6024fc24b0b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180309160427) do +ActiveRecord::Schema.define(version: 20180320182229) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -728,6 +728,7 @@ ActiveRecord::Schema.define(version: 20180309160427) do add_index "events", ["action"], name: "index_events_on_action", using: :btree add_index "events", ["author_id"], name: "index_events_on_author_id", using: :btree + add_index "events", ["project_id", "author_id"], name: "index_events_on_project_id_and_author_id", using: :btree add_index "events", ["project_id", "id"], name: "index_events_on_project_id_and_id", using: :btree add_index "events", ["target_type", "target_id"], name: "index_events_on_target_type_and_target_id", using: :btree @@ -1863,6 +1864,7 @@ ActiveRecord::Schema.define(version: 20180309160427) do end add_index "user_interacted_projects", ["project_id", "user_id"], name: "index_user_interacted_projects_on_project_id_and_user_id", unique: true, using: :btree + add_index "user_interacted_projects", ["user_id"], name: "index_user_interacted_projects_on_user_id", using: :btree create_table "user_synced_attributes_metadata", force: :cascade do |t| t.boolean "name_synced", default: false |