Skip to content

Optimize the Import subscribers, instead of using single query used bulk insert / upsert. #2506

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

Closed
wants to merge 1 commit into from

Conversation

amrishshah
Copy link

@amrishshah amrishshah commented May 28, 2025

Optimize the Import subscribers, instead of using single query used bulk insert / upsert. This will help to import subscribers faster compare to single query.

@amrishshah amrishshah changed the title Optimize the import Import subscribers, instead of using single query used bulk insert / upsert. Optimize the Import subscribers, instead of using single query used bulk insert / upsert. May 29, 2025
@knadh
Copy link
Owner

knadh commented Jun 6, 2025

Hi @amrishshah. Have you benchmarked this against the current approach? How big of an improvement is the JSON approach?

The import isn't doing one round trip query per record currently, by the way. It's batching N inserts doing doing a single commit.

@amrishshah
Copy link
Author

amrishshah commented Jun 6, 2025

@knadh , I agree it is taking one round trip, but I think while committing the transaction it will take time as there is a SELECT query while updating the subscriber_lists

I am attaching screenshot of 30k User

This is taking approx. 1 minute to import.

image

with bulk import it is taking 3 sec.

image

listmonk=# select count(id) from subscribers;
count

31654
(1 row)

listmonk=# select count(*) from subscriber_lists;
count

63308
(1 row)

@knadh knadh self-assigned this Jul 2, 2025
@knadh
Copy link
Owner

knadh commented Aug 3, 2025

Hi @amrishshah. Finally got around to reviewing this. 30k users taking 60 seconds to import is very unusual. From the very first release, I've benchmarked uploads at around ~10k/sec on my commodity laptop. Can you share your system's specs?

I just re-tested it with v5.0.3 and here's 50k records being imported in ~5 seconds on my system.

image

@amrishshah
Copy link
Author

amrishshah commented Aug 3, 2025

Hi @knadh, my laptop configuration is 16 gb ram and SSD hard disk.

image

@amrishshah
Copy link
Author

amrishshah commented Aug 4, 2025

hi @knadh , if it is working let not waste time and closing the request.

@amrishshah amrishshah closed this Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants