# Batch creation of contacts via API is slow

**URL:** <https://forum.mautic.org/t/batch-creation-of-contacts-via-api-is-slow/33206>\
**Category:** Product Support\
**Created:** [August 22, 2024, 2:42pm UTC](https://forum.mautic.org/t/batch-creation-of-contacts-via-api-is-slow/33206 "2024-08-22T14:42:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilkkao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ilkkao/32/12562_2.png) [@ilkkao](https://forum.mautic.org/u/ilkkao)\
**Post date:** [August 22, 2024, 2:42pm UTC](https://forum.mautic.org/t/batch-creation-of-contacts-via-api-is-slow/33206/1 "2024-08-22T14:42:33Z")

</div>

**Your software**  
My Mautic version is: 5.1.0  
My PHP version is: 8.1.29  
My Database type and version is: mysql 8.0

**Your problem**  
My problem is:

Now after switching to Mautic 5 (clean install) I have to do a full contacts sync. I’ve about 7 million contacts to sync.

Mautic 4 handled this full sync in a reasonable time. But now with Mautic 5, the speed is about 1 new contact created per second. I’m using `POST contacts/batch/new` endpoint. Different batch sizes (1-200) doesn’t seem to affect the overall speed.

So far I have already given Mautic a beefy database with 64GB of ram. Also mautic itself has 60GB of ram. This setup is running in Azure.

Has anybody else seen this regression? Any tricks to optimize or debug the situation? What I can see from the monitoring is that neither the database nor the mautic web container are CPU saturated. I’m puzzled what the bottleneck can be.

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [August 22, 2024, 2:49pm UTC](https://forum.mautic.org/t/batch-creation-of-contacts-via-api-is-slow/33206/2 "2024-08-22T14:49:35Z")

</div>

There are some discussions happening on Slack about this, possibly because there’s an index missing on the leads.email: [Slack](https://mautic.slack.com/archives/C02L1C6UFHQ/p1720676764250719)

---

<div class="post-metadata">

**Author:** ![ilkkao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ilkkao/32/12562_2.png) [@ilkkao](https://forum.mautic.org/u/ilkkao)\
**Post date:** [August 22, 2024, 3:05pm UTC](https://forum.mautic.org/t/batch-creation-of-contacts-via-api-is-slow/33206/3 "2024-08-22T15:05:23Z")

</div>

> [@silavapi](#):
>
> Slack

Thanks! Looks indeed the same issue. I’ll create that index by hand and report back to Slack what happened
