From 6aaef5c34e4165daef1a69fa33d7ee5b1b8b5d95 Mon Sep 17 00:00:00 2001 From: KMY Date: Sat, 16 Sep 2023 13:42:55 +0900 Subject: [PATCH] Fix N+1 problem on statuses/public_statuses indices --- app/chewy/public_statuses_index.rb | 2 +- app/chewy/statuses_index.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/chewy/public_statuses_index.rb b/app/chewy/public_statuses_index.rb index 4bfe3f08ad39db..fc58f8f097f2a5 100644 --- a/app/chewy/public_statuses_index.rb +++ b/app/chewy/public_statuses_index.rb @@ -144,7 +144,7 @@ class PublicStatusesIndex < Chewy::Index index_scope ::Status.unscoped .kept .indexable - .includes(:media_attachments, :preloadable_poll, :preview_cards, :tags) + .includes(:media_attachments, :preloadable_poll, :preview_cards, :tags, :account) root date_detection: false do field(:id, type: 'long') diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index 3b0a38a466f26f..6a6621fb8cd13e 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -145,6 +145,7 @@ class StatusesIndex < Chewy::Index settings index: index_preset(refresh_interval: '30s', number_of_shards: 5), analysis: Rails.env.test? ? DEVELOPMENT_SETTINGS : PRODUCTION_SETTINGS index_scope ::Status.unscoped.kept.without_reblogs.includes( + :account, :media_attachments, :preview_cards, :local_mentioned,