Mautic segment update is taking too long

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

Steps I have tried to fix the problem :

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?


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


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

We have 225570 identified contacts (with email).

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.

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

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


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.

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

@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

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.

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

And will this help 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


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

1 Like

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

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