chore: Improved indexes for Conversations & Contacts [CW-3300] (#9475)

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
This commit is contained in:
Sojan Jose
2024-05-15 16:10:39 -07:00
committed by GitHub
parent 7ed375f6f5
commit 8520846b91
4 changed files with 14 additions and 3 deletions

View File

@@ -25,6 +25,7 @@
# Indexes
#
# index_contacts_on_account_id (account_id)
# index_contacts_on_account_id_and_last_activity_at (account_id,last_activity_at DESC NULLS LAST)
# index_contacts_on_blocked (blocked)
# index_contacts_on_lower_email_account_id (lower((email)::text), account_id)
# index_contacts_on_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin