Fix: ancestor_status_id検索によるDB負荷 (#318)

This commit is contained in:
KMY(雪あすか) 2023-11-30 12:55:50 +09:00 committed by GitHub
parent a88349af55
commit eb7cf381ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
class AddIndexOnConversationsAncestorStatusId < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def change
add_index :conversations, :ancestor_status_id, where: 'ancestor_status_id IS NOT NULL', algorithm: :concurrently
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2023_11_15_001356) do
ActiveRecord::Schema[7.1].define(version: 2023_11_30_031209) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -477,6 +477,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_11_15_001356) do
t.datetime "updated_at", precision: nil, null: false
t.string "inbox_url"
t.bigint "ancestor_status_id"
t.index ["ancestor_status_id"], name: "index_conversations_on_ancestor_status_id", where: "(ancestor_status_id IS NOT NULL)"
t.index ["uri"], name: "index_conversations_on_uri", unique: true, opclass: :text_pattern_ops, where: "(uri IS NOT NULL)"
end