From b6355bb0ed81a12c39cb8e559c6715ecf4cfe62c Mon Sep 17 00:00:00 2001 From: takayamaki Date: Thu, 30 Nov 2017 02:23:51 +0900 Subject: [PATCH] add index on stream_entries table --- db/migrate/20171129172043_add_index_on_stream_entries.rb | 7 +++++++ db/schema.rb | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20171129172043_add_index_on_stream_entries.rb diff --git a/db/migrate/20171129172043_add_index_on_stream_entries.rb b/db/migrate/20171129172043_add_index_on_stream_entries.rb new file mode 100644 index 0000000000000..478530c7fdb34 --- /dev/null +++ b/db/migrate/20171129172043_add_index_on_stream_entries.rb @@ -0,0 +1,7 @@ +class AddIndexOnStreamEntries < ActiveRecord::Migration[5.1] + def change + commit_db_transaction + add_index :stream_entries, [:account_id, :activity_type, :id], algorithm: :concurrently + remove_index :stream_entries, name: :index_stream_entries_on_account_id + end +end diff --git a/db/schema.rb b/db/schema.rb index f2ef60375cf23..71674ece6268f 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: 20171125190735) do +ActiveRecord::Schema.define(version: 20171129172043) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -431,7 +431,7 @@ t.datetime "updated_at", null: false t.boolean "hidden", default: false, null: false t.bigint "account_id" - t.index ["account_id"], name: "index_stream_entries_on_account_id" + t.index ["account_id", "activity_type", "id"], name: "index_stream_entries_on_account_id_and_activity_type_and_id" t.index ["activity_id", "activity_type"], name: "index_stream_entries_on_activity_id_and_activity_type" end