mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
Based on our recent performant optimisation exercises, We have identified a better indexing strategy for conversations and contacts. The previous index on last_activity_at for conversations significantly slowed down conversation filters. Similarly, the new index on Contacts will allow the page rendering to improve for accounts with many contacts. fixes: https://linear.app/chatwoot/issue/CW-3300/db-improvements
12 lines
411 B
Ruby
12 lines
411 B
Ruby
class IndexImprovementsConversationsContacts < ActiveRecord::Migration[7.0]
|
|
disable_ddl_transaction!
|
|
|
|
def change
|
|
remove_index :conversations, :last_activity_at
|
|
add_index :contacts, [:account_id, :last_activity_at],
|
|
order: { last_activity_at: 'DESC NULLS LAST' },
|
|
algorithm: :concurrently,
|
|
name: 'index_contacts_on_account_id_and_last_activity_at'
|
|
end
|
|
end
|