How to delete Unused data and reduce DB Size

Hi Team,

The DB has lots of Email Queue Records and Shopify Logs which are irrelevant now. Both these occupy more than 50% of the database size.

I tried deleting the some of the records, still i didn’t see any improvements in DB Size.

Is it possible to reduce the DB Size and delete the irrelevant data?

Thanks,
Saravana

1 Like

Great question, I’m analyzing a similar situation but with general error logs (Not email queue or Shopify)

If you deleted and didn’t see any improvements perhaps they aren’t the culprit? THough email queue appears to be usual culprit. (Check log settings and set # of days after which email queue will be cleared)

Shopify success logs are also mostly irrelevant. You can delete them, planning to add an automated job for this.

In MySQL databases, deleting table rows does not automatically shrink the files on disk.

It’s complicated, but the article below explains a little. The section you’ll want to read is titled “Shrink and Optimize MySQL”
https://www.forknerds.com/reduce-the-size-of-mysql/

TLDR : To regain disk space, you probably need to:

  1. Take a backup.
  2. Drop the database completely (which removes the files on disk)
  3. Then restore from the backup.
1 Like

I believe there is a setting that clears up logs after x amount of days. I just set it to 10 days to see if that helps.

1 Like