chore: Add Index for widget contact lookup (#6998)
- Adds an index to improve the contact lookup performance while calling setUser from widget
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_contacts_on_account_id (account_id)
|
# 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_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin
|
||||||
# index_contacts_on_phone_number_and_account_id (phone_number,account_id)
|
# index_contacts_on_phone_number_and_account_id (phone_number,account_id)
|
||||||
# uniq_email_per_account_contact (email,account_id) UNIQUE
|
# uniq_email_per_account_contact (email,account_id) UNIQUE
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class AddIndexForWidgetContactLookUp < ActiveRecord::Migration[6.1]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
add_index :contacts, 'LOWER(email), account_id', name: 'index_contacts_on_lower_email_account_id', algorithm: :concurrently
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_04_18_100944) do
|
ActiveRecord::Schema.define(version: 2023_04_26_130150) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
@@ -405,6 +405,7 @@ ActiveRecord::Schema.define(version: 2023_04_18_100944) do
|
|||||||
t.string "identifier"
|
t.string "identifier"
|
||||||
t.jsonb "custom_attributes", default: {}
|
t.jsonb "custom_attributes", default: {}
|
||||||
t.datetime "last_activity_at"
|
t.datetime "last_activity_at"
|
||||||
|
t.index "lower((email)::text), account_id", name: "index_contacts_on_lower_email_account_id"
|
||||||
t.index ["account_id"], name: "index_contacts_on_account_id"
|
t.index ["account_id"], name: "index_contacts_on_account_id"
|
||||||
t.index ["email", "account_id"], name: "uniq_email_per_account_contact", unique: true
|
t.index ["email", "account_id"], name: "uniq_email_per_account_contact", unique: true
|
||||||
t.index ["identifier", "account_id"], name: "uniq_identifier_per_account_contact", unique: true
|
t.index ["identifier", "account_id"], name: "uniq_identifier_per_account_contact", unique: true
|
||||||
|
|||||||
Reference in New Issue
Block a user