Add: #641 preview_cardsmedia_attachmentsにインデックスを追加 (#674)

This commit is contained in:
KMY(雪あすか) 2024-03-27 08:42:08 +09:00 committed by GitHub
parent b3510acc32
commit a4523b833d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
class ImprovePreviewCardsVacuum < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def change
add_index :preview_cards, :id, name: 'index_preview_cards_vacuum', where: "image_file_name IS NOT NULL AND image_file_name <> ''", algorithm: :concurrently
add_index :media_attachments, :id, name: 'index_media_attachments_vacuum', where: "file_file_name IS NOT NULL AND remote_url <> ''", 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: 2024_03_22_161611) do
ActiveRecord::Schema[7.1].define(version: 2024_03_26_231854) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -853,6 +853,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_22_161611) do
t.datetime "thumbnail_updated_at", precision: nil
t.string "thumbnail_remote_url"
t.index ["account_id", "status_id"], name: "index_media_attachments_on_account_id_and_status_id", order: { status_id: :desc }
t.index ["id"], name: "index_media_attachments_vacuum", where: "((file_file_name IS NOT NULL) AND ((remote_url)::text <> ''::text))"
t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id", where: "(scheduled_status_id IS NOT NULL)"
t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true, opclass: :text_pattern_ops, where: "(shortcode IS NOT NULL)"
t.index ["status_id"], name: "index_media_attachments_on_status_id"
@ -1178,6 +1179,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_22_161611) do
t.integer "link_type"
t.datetime "published_at"
t.string "image_description", default: "", null: false
t.index ["id"], name: "index_preview_cards_vacuum", where: "((image_file_name IS NOT NULL) AND ((image_file_name)::text <> ''::text))"
t.index ["url"], name: "index_preview_cards_on_url", unique: true
end

View file

@ -95,6 +95,7 @@ namespace :dangerous do
20240229233617
20240312230204
20240320231633
20240326231854
)
# Removed: account_groups
target_tables = %w(
@ -177,6 +178,8 @@ namespace :dangerous do
target_indices = %w(
index_statuses_on_url
index_statuses_on_conversation_id
index_preview_cards_vacuum
index_media_attachments_vacuum
)
prompt.say 'Processing...'