# How to shrink Bloated MySQL db?

**URL:** <https://forum.mautic.org/t/how-to-shrink-bloated-mysql-db/6434>\
**Category:** Product Support\
**Created:** [November 3, 2016, 7:29pm UTC](https://forum.mautic.org/t/how-to-shrink-bloated-mysql-db/6434 "2016-11-03T19:29:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![coh998](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@coh998](https://forum.mautic.org/u/coh998)\
**Post date:** [November 3, 2016, 7:29pm UTC](https://forum.mautic.org/t/how-to-shrink-bloated-mysql-db/6434/1 "2016-11-03T19:29:55Z")

</div>

Sent 4 messages to a contact list of 16,467.  
  
  
  
SiteGround host informs me that I’ve exceeded allowable MySQL database size of 750MB.  
  
  
  
How can I shrink that? I tried setting Table “email\_stats” column “copy\_id” to null, but foreign key restraint prohibits modification of that data.  
  
  
  
I don’t care about stats after the second week since sending. What is the best/easiest method to reduce that database size?

---

<div class="post-metadata">

**Author:** ![coh998](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@coh998](https://forum.mautic.org/u/coh998)\
**Post date:** [November 3, 2016, 7:29pm UTC](https://forum.mautic.org/t/how-to-shrink-bloated-mysql-db/6434/2 "2016-11-03T19:29:55Z")

</div>

Sent 4 messages to a contact list of 16,467.

SiteGround host informs me that I’ve exceeded allowable MySQL database size of 750MB.

How can I shrink that? I tried setting Table “email\_stats” column “copy\_id” to null, but foreign key restraint prohibits modification of that data.

I don’t care about stats after the second week since sending. What is the best/easiest method to reduce that database size?

---

<div class="post-metadata">

**Author:** ![swip](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@swip](https://forum.mautic.org/u/swip)\
**Post date:** [November 4, 2016, 2:50pm UTC](https://forum.mautic.org/t/how-to-shrink-bloated-mysql-db/6434/3 "2016-11-04T14:50:16Z")

</div>

Have you tried this, from [https://mautic.org/docs/en/setup/cron\_jobs.html](https://mautic.org/docs/en/setup/cron_jobs.html)

[quote]Cleanup Old Data

Cleanup a Mautic installation by purging old data. Note that not all data is able to be purged. Currently supported are audit log entries, visitors (anonymous contacts), and visitor page hits. Use --dry-run to view the number of records to be purged before making any changes.

This will permanently delete data! Be sure to keep database backups.[/quote]

```auto
php /path/to/mautic/app/console mautic:maintenance:cleanup --days-old=365 --dry-run
```

---

<div class="post-metadata">

**Author:** ![coh998](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@coh998](https://forum.mautic.org/u/coh998)\
**Post date:** [November 5, 2016, 6:35pm UTC](https://forum.mautic.org/t/how-to-shrink-bloated-mysql-db/6434/4 "2016-11-05T18:35:45Z")

</div>

No, I haven’t, because that’s not where the whopping gobs of data in question are stored. There’s a copy of every single message - not just a reference to the original, but the entire message for every recipient—thousands of them, archived for individual tracking purposes. I tried to clear that data manually from the database: Table “email\_stats”; column “copy\_id” but there is a foreign key restraint on that data. Can’t seem to drop the column, either.

How can I delete that specific data, or achieve the same result, without destroying any dependencies or else wise screwing other things up?

---

<div class="post-metadata">

**Author:** ![eplaku](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/eplaku/32/49_2.png) [@eplaku](https://forum.mautic.org/u/eplaku)\
**Post date:** [April 26, 2017, 9:48am UTC](https://forum.mautic.org/t/how-to-shrink-bloated-mysql-db/6434/5 "2017-04-26T09:48:08Z")

</div>

+1
