Home > Tracking Campaigns > FunnelFlux

Database Optimization (5)


11-27-2016 07:59 PM #1 bizfreak22 (Member)
Database Optimization

Hey guys,

So I got lazy and let my DB get pretty huge, over 50 gigs already..I deleted a month's worth of stats in FF, but when I checked the DB, the size was the same..I was told that I have to optimize the DB to get the space back.. does anyone know the query to do that when it relates to FunnelFlux?

Thanks!


11-27-2016 08:17 PM #2 matuloo (Legendary Moderator)

Let me ping the funnelflux guys to chime in and help you if possible.


11-28-2016 03:12 AM #3 Mr Baffoe (Veteran Member)

The command is:

Optimize table [[tablename]]

Where [[tablename]] is the table you deleted from.

Be aware that unless you are on MySQL 5.7.4, running the command will most likely lock up the table during the entire process. Which means nothing would be saved to it etc. For 50 gig db, not sure the size of the table, that could take a while.

To do this with less downtime you would need to copy all the data to a new table, and switch the table names when complete. This is only viable if you have enough space to have both tables at the same time.


11-28-2016 04:43 PM #4 vitavee ()

Thanks a lot @Nana!

I actually already replied in the support chat this morning, but I'm going to post it here for reference - my reply below includes compressing the table.

it's done in 3 steps and you need to have at least 50% free space on your disk.

1st step:
In your MySQL configuration file, check if you have the option innodb_file_per_table set to 1
Otherwise the compression won't work
If it is not set to 1, you cannot simply turn it to 1 now - there is a procedure to follow to turn it "on" on existing databases:
http://dba.stackexchange.com/questio...-for-a-live-db

2nd step:
Stop all traffic then run the following MySQL commands one by one:

Code:
create table `compressed_stats_root_4` like `stats_root`;
alter table `compressed_stats_root_4` key_block_size=4 row_format=compressed;
insert into `compressed_stats_root_4` select * from `stats_root`;
rename table `stats_root` TO `stats_root_old`;
rename table `compressed_stats_root_4` TO `stats_root`;
This will create a compressed copy of your stats_root table, but the old stats_root will still be there.
Check your drilldowns to see if you can pull hit-id reports.

If yes, then go to step 3... otherwise get your old table back with the 2 commands below:

drop table `stats_root`;
rename table `stats_root_old` TO `stats_root`;

3rd step
Delete the old table with this command:

Code:
drop table `stats_root_old`;
it should make your stats_root table between 1/4 to 1/3 its current size without any negative effect on the speed


11-29-2016 05:11 AM #5 bizfreak22 (Member)

Thanks everyone!!


Home > Tracking Campaigns > FunnelFlux