Very Large aow_processed and aow_processed_aow_actions tables.
I was making another dev copy of my crm to test the new 7.7 upgrade. So as I went to copy the DB I was prepared to move about 17GB of data. Then I started thinking, why don’t I just export with --no-data for mysqldump. But I still need info like the users, roles, etc, to test. Then I though “well then I’ll simply do a separate mysql dump of the tables I need data in”.
As I go to browse, curiously, I thought, hmm let me sort by largest to the smallest table by size and see what the culprit is. Sure enough aow_processed and aow_processed_aow_actions where, in total, about ~15gb.
I never noticed this whole time that the prune DB scheduler was never running. On top of that, I have a master slave db setup as backup and performance. So I wanted to include how I manually pruned the DB with those 2 tables. I cannot use Truncate as it will not be replicated on my slave.
First I will CREATE a copy of the table, and keep the data for the last day. I went to cli and logged into mysql
mysql -u root -p
Then I needed to select my database. Make a copy of the aow_processed table, keeping just today’s data, and then renaming the tables.
USE mycrmdb;
CREATE TABLE aow_processed_new AS SELECT * FROM aow_processed WHERE date_entered >= '2016-09-20 00:00:00';
ALTER TABLE aow_processed RENAME aow_processed_old;
ALTER TABLE aow_processed_new RENAME aow_processed;
Then I simply need to DROP the old aow_processed DB. NOW please do not do this if you do not know what you are doing. Do not go dropping tables by accident without backups and killing your data. OK, warning over.
DROP TABLE aow_processed_old;
That is the quickest method of pruning that TABLE. I had about 50 million records in aow_processed and it took about 10GB. Yikes.
Repeat for aow_processed_aow_actions table and you are all set. No more enormous DB.