From f880f1a42ffc39cd65eeaf318682b166290fd1d4 Mon Sep 17 00:00:00 2001 From: Michael Fitz-Payne Date: Mon, 4 Mar 2024 13:50:01 +1000 Subject: [PATCH] DEV: add topic_id index to incoming_emails table (#26004) This table may grow to be large, and an index on this column improves performance for SELECT queries. --- app/models/incoming_email.rb | 1 + .../20240304030429_topic_id_on_incoming_email_index.rb | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 db/migrate/20240304030429_topic_id_on_incoming_email_index.rb diff --git a/app/models/incoming_email.rb b/app/models/incoming_email.rb index 9092eb28349..bd77ed8bee5 100644 --- a/app/models/incoming_email.rb +++ b/app/models/incoming_email.rb @@ -104,5 +104,6 @@ end # index_incoming_emails_on_imap_sync (imap_sync) # index_incoming_emails_on_message_id (message_id) # index_incoming_emails_on_post_id (post_id) +# index_incoming_emails_on_topic_id (topic_id) # index_incoming_emails_on_user_id (user_id) WHERE (user_id IS NOT NULL) # diff --git a/db/migrate/20240304030429_topic_id_on_incoming_email_index.rb b/db/migrate/20240304030429_topic_id_on_incoming_email_index.rb new file mode 100644 index 00000000000..43d378313d5 --- /dev/null +++ b/db/migrate/20240304030429_topic_id_on_incoming_email_index.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +class TopicIdOnIncomingEmailIndex < ActiveRecord::Migration[7.0] + disable_ddl_transaction! + + def change + add_index :incoming_emails, :topic_id, algorithm: :concurrently + end +end