Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize curated addresses #945

Merged
merged 1 commit into from
Mar 18, 2024
Merged

Conversation

matiasgarciaisaia
Copy link
Member

@matiasgarciaisaia matiasgarciaisaia commented Mar 15, 2024

When queueing calls with a specific call flow from the Projects page, we first check we don't call the same Contact twice (ie, if the user pasted two different phones of the same contact at the same time).

If the project's address book grew large, the method is really slow when mapping contact addresses to contacts, because it loads every contact address for the project from the database - and iterating over them. We've seen this method take ~20 seconds with ~365k contacts in a production environment.

This PR changes the method so it only works with the Contacts of the given phone numbers instead of every contact of the project. We now do two queries to the DB instead of a single one, but we query via an index, and significantly reduce the amount of records to work with.

See #944

If the address book grows large, the method was really slow when mapping
contact addresses to contacts. We now restrict it to only work with the
contacts of the addresses it's working on.

See #944
@matiasgarciaisaia
Copy link
Member Author

@ggiraldez could you check the original commit (fee045a) to see if we're missing any test case?

Copy link

@mverzilli mverzilli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@matiasgarciaisaia matiasgarciaisaia merged commit 509bcd0 into master Mar 18, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants