My Mautic version is: 2.6.15
My PHP version is: 7.3
Database over time grew quite large. Almost all of the data is in tables:
Is there a safe way to get rid of them? The number of contacts is already trimmed to 365 days with the mautic:maintenance:cleanup
However - this seems not to cleanup the events logs?
How can we save remove records?
How old is your oldest event?
Earliest event is from 05/2018…
Maybe you should delete everything, that is really old:
The Mautic database tends to grow huge very quickly, especially when integrated on higher-traffic web sites. A large percentage is basically junk, though. Here are some simple tricks to reduce that drastically.
Note that at the same time this...
Unfortunately those tipps seem always to be contact related… I would rather cleanup old events, than contacts
I don’t recommend it to everyone, but I use Dbeaver and SQLyog to tidy up.
Add your DB credentials
select the table
use the filters to identify events you want to delete
Select all and delete.
Make a backup before you start of course
I do the same.
And I also don’t recommend it
php /path/to/mautic/app/console mautic:maintenance:cleanup --days-old=365 --dry-run
This only deletes:
The above entries (apprx 900 entries) happened in 4-5 days on a site where I only have around 50 visitors / day. You should try the dry run and see what happens, it won’t delete anything just give you heads up.
thanks, thats what I did first
will investigate into what you both don’t recommend.
probably I will not recommend it either and do it too.
We did the following to cleanup our mautic database:
DELETE FROM campaign_lead_event_log WHERE date_triggered < (NOW() - INTERVAL 60 DAY);
UPDATE campaign_lead_event_log SET metadata = ‘’;
DELETE from lead_event_log where bundle=“lead” and object=“import” WHERE date_added < (NOW() - INTERVAL 30 DAY);
But very important:
Dont forget to do the folowing
OPTIMIZE LOCAL TABLE campaign_lead_event_log;
OPTIMIZE LOCAL TABLE lead_event_log;
Only after this command you free up the space.
We got this from this ticket here:
Sorry one thing:
Maybe you want to increase the INTERVAL xx DAY to fit your needs
So there are no vital dependencies, that expect the event logs to exist completely?
I used the statements several times and did not recognized any issue with that.
But in the issue one user wrotes:
Be careful with it!
If you have some campaign waiting for “page visits” you can break it.
I tested these queries, and I have caused many messages in my GDPR workflow to be sent again.
My campaign looks like “for new contacts in segment A, send an email, and wait for visits to confirmation-page to move them to another segment.”
I hope you find this message useful.
You could also adapt the sql query and use it only for campaigns which are no longer are active.
I would suggest:
Copy your installation to a staging installation and stop the mail cronjobs for this installation.
Clean the database on the staging installation like you would on the live enviroment and check the mail spool folder for emails to appear.
If there are emails in the spool, chances are high that you trigger some campaigns again. But in my experience this happens rarely if you use an day interval big enough in the query.
You can run
mautic:campaigns:validate to see if there are inactive contacts hung up in your campaign as well