dirk_s
January 22, 2021, 5:20pm
1
Your software
My Mautic version is: 2.6.15
My PHP version is: 7.3
Your problem
Database over time grew quite large. Almost all of the data is in tables:
campaign_lead_event_log and
lead_event_log
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?
joeyk
January 23, 2021, 11:05am
2
How old is your oldest event?
Joey
dirk_s
January 24, 2021, 8:09pm
3
Earliest event is from 05/2018ā¦
joeyk
January 24, 2021, 8:18pm
4
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...
1 Like
dirk_s
January 26, 2021, 10:54am
5
Unfortunately those tipps seem always to be contact relatedā¦ I would rather cleanup old events, than contacts
EJL
January 26, 2021, 4:02pm
6
I donāt recommend it to everyone, but I use Dbeaver and SQLyog to tidy up.
Add your DB credentials
connect
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
2 Likes
joeyk
January 26, 2021, 5:34pm
7
I do the same.
And I also donāt recommend it
3 Likes
joeyk
January 26, 2021, 5:37pm
8
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.
dirk_s
January 26, 2021, 10:47pm
9
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.
1 Like
Hi Dirk
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:
Greetings
Sebastian
5 Likes
Sorry one thing:
Maybe you want to increase the INTERVAL xx DAY to fit your needs
1 Like
dirk_s
January 28, 2021, 5:06pm
12
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.
1 Like
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.
1 Like
EJL
January 29, 2021, 4:38pm
15
You can run mautic:campaigns:validate to see if there are inactive contacts hung up in your campaign as well
3 Likes
Hi Sebastian,
why did you use this line
DELETE from lead_event_log where bundle=āleadā and object=āimportā WHERE date_added < (NOW() - INTERVAL 30 DAY);
?
Is it only to get rid of the import event in the logs? I mean from imported contacts?
Cheers,
Alex
HI Alex
Is it only to get rid of the import event in the logs? I mean from imported contacts?
Yes, exactly. If your clients use a lot of imports (or if you have something like a hotfolder import ) this gets really huge. But you donāt need to delete this.
greetings
Sebastian
1 Like
Yes I thought so. Thank you Sebastian
1 Like
Hey Alex
I would like to recommend you this thread regarding the db cleanup:
Hey Instamaker
You could do this commands on the shell (backup + on your own risk!)
We do them regularly but I could give you no garanty.
There is a new plugin which does some campaign_lead_event_log cleanups:
https://github.com/Leuchtfeuer/mautic-housekeeping-bundle
**Update: **
Sorry made a mistake in the audit log statement. Fixed it in the gist.
Greetings
Sebastian
I also published our intern db cleanup script there.
Direct link to my gist in the thread:
Greetings
Sebastian
2 Likes