# Mautic segment update is taking too long

**URL:** <https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [September 25, 2023, 10:11am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419 "2023-09-25T10:11:46Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anil\_naut111](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anil_naut111/32/6472_2.png) [@anil\_naut111](https://forum.mautic.org/u/anil_naut111)\
**Post date:** [September 25, 2023, 10:11am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/1 "2023-09-25T10:11:47Z")

</div>

**Your software**  
_My PHP version is_ : 7.4.29  
_My MySQL/MariaDB version is_ (delete as applicable): MySQL/MariaDB version 5.7.42  
SERVER: GCP compute engine vCPUs 2 Memory 7.5 GB

**Your problem**  
_My problem is_ : Segment update cron task(php /var/www/html/mautic/bin/console mautic:segments:update) is taking too much time to update, so I want to know is this dependent on number of filters I am using, or what things can be impacting this.

Filter I am using

 ![Screenshot (11)](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/1/114d01f4a4e2f90440f670273ebce307c017b0e6.png)

_Steps I have tried to fix the problem_ :

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [September 27, 2023, 7:23am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/2 "2023-09-27T07:23:53Z")

</div>

Hi, it depends how large is your DB, especially your leads (leads) and sent emails list (email\_stats).  
Also: depends how many segments you have.  
BTW how often you run segment update via cron?

Joey

---

<div class="post-metadata">

**Author:** ![anil\_naut111](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anil_naut111/32/6472_2.png) [@anil\_naut111](https://forum.mautic.org/u/anil_naut111)\
**Post date:** [September 27, 2023, 7:50am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/3 "2023-09-27T07:50:54Z")

</div>

Hello @joeyk we run segment update daily. Our DB size is 20GB, and we have 10 segments.

Anil

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [September 27, 2023, 3:34pm UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/4 "2023-09-27T15:34:01Z")

</div>

How many identified contacts (with email) you have in your system?

---

<div class="post-metadata">

**Author:** ![anil\_naut111](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anil_naut111/32/6472_2.png) [@anil\_naut111](https://forum.mautic.org/u/anil_naut111)\
**Post date:** [September 27, 2023, 3:59pm UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/5 "2023-09-27T15:59:32Z")

</div>

We have 225570 identified contacts (with email).

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [September 29, 2023, 8:26am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/6 "2023-09-29T08:26:08Z")

</div>

Hello,  
That is not a huge about of segments.  
Could you please show here the cronjob command you use for segment update?  
It would be nice to see how often you run it.  
Joey

---

<div class="post-metadata">

**Author:** ![anil\_naut111](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anil_naut111/32/6472_2.png) [@anil\_naut111](https://forum.mautic.org/u/anil_naut111)\
**Post date:** [September 29, 2023, 9:51am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/7 "2023-09-29T09:51:21Z")

</div>

Hello, here is the segment update commend and we run it daily once.

php /var/www/html/mautic/bin/console mautic:segments:update

Thanks

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 29, 2023, 9:56am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/8 "2023-09-29T09:56:19Z")

</div>

can you turn off the cronjob for the time being and try to run command directly in terminal.

See if any issues display in stdout. Also follow the log and see if any entries pop up when you run update manually.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [September 29, 2023, 10:06am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/9 "2023-09-29T10:06:14Z")

</div>

Could you share the values BEFORE the php?  
is it `* * * * *` or rather `0,15,30,45 * * * *` or maybe `*/5 * * * *`?

---

<div class="post-metadata">

**Author:** ![anil\_naut111](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anil_naut111/32/6472_2.png) [@anil\_naut111](https://forum.mautic.org/u/anil_naut111)\
**Post date:** [September 29, 2023, 10:08am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/10 "2023-09-29T10:08:24Z")

</div>

@joeyk we are running it manually as it same on ssh, not as cron commend.  
php /var/www/html/mautic/bin/console mautic:segments:update

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [September 29, 2023, 10:11am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/11 "2023-09-29T10:11:46Z")

</div>

Okay, we are getting there.  
How long it takes until it runs for 200.000 contacts.  
I did a similar task yesterday it was 40 min, but we had 200k contacts assigned to different segments the first time.  
If you run it again, only the changes will be updated, and it’s really fast.

---

<div class="post-metadata">

**Author:** ![anil\_naut111](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anil_naut111/32/6472_2.png) [@anil\_naut111](https://forum.mautic.org/u/anil_naut111)\
**Post date:** [October 4, 2023, 1:42pm UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/12 "2023-10-04T13:42:08Z")

</div>

Hello @joeyk I am curious will email\_stats table size can slow down the segment update.

And will this help [https://joeykeller.com/the-great-mautic-weight-control/](https://the-great-mautic-weight-control) in mautic segment update.

One more point as we have implemented mautic as multitenancy way(_single code instance and multiple DB_), is this may be the reason of our mautic segment update slowdown.

In total we have 15 mautic runnig from the same code instance, and total DB size is 400GB

Thanks.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 4, 2023, 2:27pm UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/13 "2023-10-04T14:27:38Z")

</div>

Yeah for sure. Problems arise exponentially as your DB grows.

---

<div class="post-metadata">

**Author:** ![anil\_naut111](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/anil_naut111/32/6472_2.png) [@anil\_naut111](https://forum.mautic.org/u/anil_naut111)\
**Post date:** [October 4, 2023, 3:46pm UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/14 "2023-10-04T15:46:09Z")

</div>

Thanks @joeyk I will try this then I hope things will get sorted.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [October 6, 2023, 3:46am UTC](https://forum.mautic.org/t/mautic-segment-update-is-taking-too-long/29419/15 "2023-10-06T03:46:58Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
