From a34aa6d902ff32346bbf8103733f7f04e2537928 Mon Sep 17 00:00:00 2001 From: KMY Date: Sat, 7 Oct 2023 21:45:46 +0900 Subject: [PATCH] =?UTF-8?q?#66=20=E3=82=A4=E3=83=B3=E3=83=87=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E3=82=92=E4=BD=9C=E3=82=8B=E6=96=B9=E5=90=91?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7090808_improve_search_for_account_statuses.rb | 15 +++++++++++++++ db/schema.rb | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20231007090808_improve_search_for_account_statuses.rb diff --git a/db/migrate/20231007090808_improve_search_for_account_statuses.rb b/db/migrate/20231007090808_improve_search_for_account_statuses.rb new file mode 100644 index 0000000000..e1817ed95c --- /dev/null +++ b/db/migrate/20231007090808_improve_search_for_account_statuses.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require Rails.root.join('lib', 'mastodon', 'migration_helpers') + +class ImproveSearchForAccountStatuses < ActiveRecord::Migration[7.0] + include Mastodon::MigrationHelpers + + disable_ddl_transaction! + + def change + safety_assured do + add_index :statuses, [:account_id, :reblog_of_id, :deleted_at, :searchability], name: 'index_statuses_for_get_following_accounts_to_search', where: 'deleted_at IS NULL AND reblog_of_id IS NULL AND searchability IN (0, 10, 1)' + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8ee0450744..32cf51a16c 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[7.0].define(version: 2023_10_01_050733) do +ActiveRecord::Schema[7.0].define(version: 2023_10_07_090808) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1203,6 +1203,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_01_050733) do t.integer "limited_scope" t.bigint "quote_of_id" t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)" + t.index ["account_id", "reblog_of_id", "deleted_at", "searchability"], name: "index_statuses_for_get_following_accounts_to_search", where: "((deleted_at IS NULL) AND (reblog_of_id IS NULL) AND (searchability = ANY (ARRAY[0, 10, 1])))" t.index ["account_id"], name: "index_statuses_on_account_id" t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)" t.index ["id", "account_id"], name: "index_statuses_local_20190824", order: { id: :desc }, where: "((local OR (uri IS NULL)) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"