feat(perf): contact page loading speed (#7629)

This commit is contained in:
Shivam Mishra
2023-07-27 13:32:22 +05:30
committed by GitHub
parent fcf0ba12d0
commit ff97536095
3 changed files with 11 additions and 1 deletions

View File

@@ -23,6 +23,7 @@
# index_contacts_on_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin
# index_contacts_on_nonempty_fields (account_id,email,phone_number,identifier) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))
# index_contacts_on_phone_number_and_account_id (phone_number,account_id)
# index_resolved_contact_account_id (account_id) WHERE (((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))
# uniq_email_per_account_contact (email,account_id) UNIQUE
# uniq_identifier_per_account_contact (identifier,account_id) UNIQUE
#

View File

@@ -0,0 +1,8 @@
class AddPartialIndexContactAccountId < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
add_index :contacts, [:account_id], where: "(email <> '' OR phone_number <> '' OR identifier <> '')",
name: 'index_resolved_contact_account_id', algorithm: :concurrently
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_07_14_054138) do
ActiveRecord::Schema[7.0].define(version: 2023_07_27_065605) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
@@ -408,6 +408,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_07_14_054138) do
t.index "lower((email)::text), account_id", name: "index_contacts_on_lower_email_account_id"
t.index ["account_id", "email", "phone_number", "identifier"], name: "index_contacts_on_nonempty_fields", where: "(((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))"
t.index ["account_id"], name: "index_contacts_on_account_id"
t.index ["account_id"], name: "index_resolved_contact_account_id", where: "(((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))"
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 ["name", "email", "phone_number", "identifier"], name: "index_contacts_on_name_email_phone_number_identifier", opclass: :gin_trgm_ops, using: :gin