Table incoming_emails consuming most space in database

סיכום מבוסס בינה מלאכותית

The discussion revolves around the incoming_emails table consuming 9 GB of disk space in a Discourse database, significantly more than other tables like posts. The user, running version v2.2.0.beta3 +82, has already reduced the delete_email_logs_after_days setting to 10 days and performed database maintenance, but no space is freed. It’s clarified that this setting only affects email logs, not the raw email data stored in the incoming_emails table. The table holds the full source of all received emails, including attachments, and is not automatically truncated. While the user can manually delete old or large emails from the table to free space, this should only be done if the emails are no longer needed and not accessible via POP3 to avoid duplicates. The issue highlights that Discourse retains raw email data indefinitely, which can lead to excessive storage use.

My discource running out of disk space.
Searching for tables wich taking most of space in database I fund that table incoming_emails taking 9 GB of my disk space.Next one table is posts it’s take only 1 GB .
I did change setting delete email logs after days from 365 to 10 , I did trigger all jobs on sidekiq, I did vacuum database , but no release of disk space.
When I query table I see that there is emails from start of forum back in 2015.

Is there any other settings on discource I can tune up to get rid of incoming_emails;
Is there any other way to purge old incoming emails so we gain disk space.

I am pretty sure we automatically truncate this table… checking .. yes, in Discourse 2.0 we changed retention from 1 year to 90 days.

My version is on v2.2.0.beta3 +82

That’s the delete_email_logs_after_days setting which only applies to email logs.

The incoming_emails table contains the raw source of all received emails. I guess you received a lot of emails that contained (large) attachments?

If you are really low on disk space and you don’t care about the original emails (the data you see when you click on the envelope image in the right, top corner of posts created via email), you could delete them manually from the database. Maybe restrict it to the older or larger emails? Deleting them shouldn’t break any essential functionality. But, please make sure, that none of those emails are available via POP3 anymore, otherwise Discourse might pull them again, which could lead to duplicate posts.

Whoa we never truncate this table.. ever? So we keep a raw original email version of all email posts forever??

Yes, exactly. Nothing gets deleted from that table.