perf: Add database index on conversations identifier (#12715)

**Problem**
Slack webhook processing was failing with 500 errors due to database
timeouts. The query `Conversation.where(identifier:
params[:event][:thread_ts]).first` was performing full table scans and
hitting PostgreSQL statement timeout.

**Solution**
Added database index on conversations.identifier and account_id.
This commit is contained in:
Muhsin Keloth
2025-10-28 15:12:46 +05:30
committed by GitHub
parent f3176afc1c
commit 7e8fe78ecd
2 changed files with 8 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
class AddIndexToConversationsIdentifier < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def change
add_index :conversations, [:identifier, :account_id], name: 'index_conversations_on_identifier_and_account_id', algorithm: :concurrently
end
end