Repository navigation
feat(perf): contact page loading speed - #7629
Merged
Merged
Conversation
✅ Deploy Preview for chatwoot-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
scmmishra
marked this pull request as ready for review
July 27, 2023 07:23
sojan-official
approved these changes
Jul 27, 2023
Member
Author
|
|
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a partial index to the
contactsvery similar to the one added here: #7175The main difference is the fields on which this index operates, in this case we only index the account_id field, this drastically helps in building the contact list query when loading the contact page
Type of change
How Has This Been Tested?
This is tested on ChatwootQA DB. Overall the performance is higher for larger accounts, for smaller accounts the performance improvement is relatively smaller, but in all cases the query takes less than half of the original
The following are the links to the query plans
Account with 6K contacts
Unoptimized: https://explain.dalibo.com/plan/ed5fg23729d02c91
Optimized: https://explain.dalibo.com/plan/fdf16065ccg3ad85
Cuts query time by 85%
Account with 23K contacts
Unoptimized: https://explain.dalibo.com/plan/a1g0e8c9d699c7d6
Optimized: https://explain.dalibo.com/plan/12b68b5h8h5399f1
Cuts query time by 96%
Account with 495K contacts
Unoptimized: https://explain.dalibo.com/plan/f45g344g7d7696g3
Optimized: https://explain.dalibo.com/plan/242bd6d1g83ac8f7
Cuts query time by 99%
Account with 2.9 M contacts
Unoptimized: https://explain.dalibo.com/plan/f2ef8467fa57b5e5
Optimized: https://explain.dalibo.com/plan/a58aa96e954b73g2
Cuts query time by 98%
Checklist: