fix: Add composite index on messages for csat_metrics API performance (#11831)
This PR adds a composite index (:account_id, :content_type, :created_at) on the table messages. This index is added as a temporary fix for performance issues in the CSAT responses controller where we query messages with account_id, content_type and created_at. The current implementation (account.message.input_csat.count) times out with millions of messages. TODO: Create a dedicated csat_survey table and add entries when surveys are sent, then query this table instead of the entire messages table for better performance.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# idx_messages_account_content_created (account_id,content_type,created_at)
|
||||
# index_messages_on_account_created_type (account_id,created_at,message_type)
|
||||
# index_messages_on_account_id (account_id)
|
||||
# index_messages_on_account_id_and_inbox_id (account_id,inbox_id)
|
||||
|
||||
Reference in New Issue
Block a user