Mautic DB Hygiene

Hi,

I am sure for many of us that have been running Mautic for a few years are starting to see that the database grows exponentially and some of the candidates for this are the
audit_logs
email_stats
campaign_lead_event_log
lead_event_log
page_hits

There is already a console command that will clean up the audit_logs on a specific date range, what can we do in the most affective way to do the same for rest ?

I have already researched this issue and it is something that repeats itself however there is no definite elegant way to take care of this. (example: email_stats table bloat · Issue #7763 · mautic/mautic · GitHub)

No one wants to loose historic data however there is a price to keeping it, speed, space, memory.
Maybe there is a way to export these big tables into a separate database so that this is still accessible, maybe not ?

And when trying to follow some of the suggestions on the net it can be quite dangerous as you do not really know what will break along the way…

So this is an open discussion for those of us that have similar problems to try and find a solution that is long lasting, safe and doable for non-technical people

2 Likes

Hello @mikew,

What is your version of Mautic?

Pierre

Most of my servers are on Digital ocean, running ubuntu, nginx and mariabd

Hi @mikew,

I’m the one who posted the “solution” in github thread you’ve mentioned. Using mautics up to latest version and can confirm the issue is still there.

The DB cleanup procedure is proven to be safe for years already, although you need to make sure you dont need the data cleaned.

There is no other way to deal with it to my knowledge. Would be happy to deal with it other than deleting data.

1 Like

Hi @jester . Thanks for the solution on GitHub and replying here as well.

I am hoping this post catches the attention of enough people that we can look at putting some kind of console command in the take care of this without people having to go into the mysql themselves. I am pretty comfortable doing this, however I am sure that many others are not.

Hi @mikew , hope so too although after many years of dealing with it without any response from mautic team I doubt this may be the case.

To fix it permanently they have to change how data is stored in database. This will require substantial efforts from programming and database management side, hence chances team will look into it are quite small.

It is not critical on small to mid size instances. I have few instances scheduling around 4m emails on daily basis and my db size is over 3Tb by now. Without procedures in place I’m terrified to predict the DB size.

1 Like

I would be a good feature to be able to delete old emails, so that Mautic would remove this data from database. In my case, the biggest table is “email_stats” (not “audit_log”). You can remove leads and emails, but data from this table is never deleted.

Hello @mikew @jvilarnau,

You can check this : Mautic Cleanup Commands · GitHub

It’s work for me.

Pierre

1 Like