
I recently had an issue with disk space over usage with a client’s Magento installation. After some investigation, I discovered that the log tables (log_url, log_url_info, log_visitor and log_visitor_info) in the Magento database were extremely large.
It doesn’t take long for these tables to get quite bloated, to the point where backing up and maintaining the Magento database can be quite time consuming and resource intense. Not to mention the space required. There is little information available on how to deal with these, besides the odd post online instructing users to truncate all the log tables. I definitely DO NOT recommend truncating these tables, as you are likely to run into referential integrity issues with foreign key constraints and a broken storefront.
Magento has provided the ability to configure log cleaning (via Magento Admin > System > Configuration > Advanced > System > Log cleaning), however, by default “Enable log cleaning” is turned off. At first, enabling log cleaning didn’t seem to work, but with some trial and error I eventually got the log cleaning via cron to run for the first time, using the following settings:

Magento Log Cleaning configuration screen shot 1
As you can see in the screen shot, I set the “Save log, days” to 0 days to force it to clear everything and set the time to 04:05 so that I could go to bed … I also had to set the “Generate schedules every” to 5 and “Schedule ahead for” to 5, to force it to run. Note however that this cron consumes a lot of server resources and will take a long time to actually clear the logs when run for the first time.
When I checked it in the morning, the database was still reporting the same table size (likely due to the index). To fix this, I ran the OPTIMISE TABLE command for each table which cleared them up.
I then set the cron settings back to default and in the log cleaning settings, I set the “Save log, days” to 7.

Magento Log Cleaning configuration screen shot 2
Hopefully this will help others out there wondering how to reduce their Magneto database size.