iachat/app/javascript/dashboard/components-next/NewConversation/components
Shivam Mishra b75ea7a762
feat: Use resolved contacts as base relation for filtering (#12520)
This PR has two changes to speed up contact filtering

### Updated Base Relation

Update the `base_relation` to use resolved contacts scope to improve
perf when filtering conversations. This narrows the search space
drastically, and what is usually a sequential scan becomes a index scan
for that `account_id`

ref: https://github.com/chatwoot/chatwoot/pull/9347
ref: https://github.com/chatwoot/chatwoot/pull/7175/

Result: https://explain.dalibo.com/plan/c8a8gb17f0275fgf#plan


## Selective filtering in Compose New Conversation

We also cost of filtering in compose new conversation dialog by reducing
the search space based on the search candidate. For instance, a search
term that obviously can’t be a phone, we exclude that from the filter.
Similarly we skip name lookups for email-shaped queries.

Removing the phone number took the query times from 50 seconds to under
1 seconds

### Comparison

1. Only Email: https://explain.dalibo.com/plan/h91a6844a4438a6a 
2. Email + Name: https://explain.dalibo.com/plan/beg3aah05ch9ade0
3. Email + Name + Phone:
https://explain.dalibo.com/plan/c8a8gb17f0275fgf
2025-09-25 15:26:44 +05:30
..
story feat: Add compose conversation components (#10457) 2024-12-05 16:31:47 -08:00
ActionButtons.vue feat: Add twilio content templates (#12277) 2025-08-29 16:13:25 +05:30
AttachmentPreviews.vue fix: RTL issues in new conversation form (#12163) 2025-08-11 14:16:48 -07:00
ComposeNewConversationForm.vue feat: Use resolved contacts as base relation for filtering (#12520) 2025-09-25 15:26:44 +05:30
ContactSelector.vue feat: Use new compose conversation in conversation sidebar (#11085) 2025-03-18 15:09:10 +05:30
ContentTemplateForm.vue feat: Add twilio content templates (#12277) 2025-08-29 16:13:25 +05:30
ContentTemplateSelector.vue feat: Add twilio content templates (#12277) 2025-08-29 16:13:25 +05:30
EmailOptions.vue feat: Add compose conversation components (#10457) 2024-12-05 16:31:47 -08:00
InboxEmptyState.vue feat: Add compose conversation components (#10457) 2024-12-05 16:31:47 -08:00
InboxSelector.vue fix: RTL issues in new conversation form (#12163) 2025-08-11 14:16:48 -07:00
MessageEditor.vue chore: Improve new conversation form (#10687) 2025-01-15 13:10:09 +05:30
WhatsAppOptions.vue feat: WhatsApp enhanced templates front end changes (#12117) 2025-08-12 18:53:19 +05:30
WhatsappTemplate.vue feat: WhatsApp enhanced templates front end changes (#12117) 2025-08-12 18:53:19 +05:30