feat(perf): contacts query performance (#7175)
* feat: use more indexable where condition * feat: add index concurrently * chore: update schema * refactor: update index name
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
# index_contacts_on_account_id (account_id)
|
||||
# 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
|
||||
# index_contacts_on_identifiable_fields (account_id,email,phone_number,identifier) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text)) # rubocop:disable Layout/LineLength
|
||||
# index_contacts_on_phone_number_and_account_id (phone_number,account_id)
|
||||
# uniq_email_per_account_contact (email,account_id) UNIQUE
|
||||
# uniq_identifier_per_account_contact (identifier,account_id) UNIQUE
|
||||
@@ -136,7 +137,7 @@ class Contact < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.resolved_contacts
|
||||
where("COALESCE(NULLIF(contacts.email,''),NULLIF(contacts.phone_number,''),NULLIF(contacts.identifier,'')) IS NOT NULL")
|
||||
where("contacts.email <> '' OR contacts.phone_number <> '' OR contacts.identifier <> ''")
|
||||
end
|
||||
|
||||
def discard_invalid_attrs
|
||||
|
||||
Reference in New Issue
Block a user