Magento is brilliant, but when it comes to database maintenance, it’s not the world’s most fantastic resource. If you have a large selection of products then it makes sense that your databases are large. However, these can be vastly increased with useless information causing them to become sluggish. Log clearing can help you keep your databases the size that they should be.
Thankfully, there’s plenty of ways you can do it yourself to keep your site running quickly. Remember to back up all of your data before trying these out.
Magento has a number of tables logging information such as customer accesses and frequently compared-products. While these tables have the ability within Magento be cleaned regularly, this is not set up as default (why??).
These tables are cleaned using the log cleaning function:
There are three ways to clean these tables.
Log cleaning in the Magento Administrator Interface
- In the Magento administrator interface, go to System > Configuration.
- Click System in the left menu under Advanced
- Enable Log Cleaning by clicking Yes under Log Cleaning.
- Set it to clean logs every two weeks.
- Save Config.
Either set up a cron job or you can perform this method manually if you need.
- In the Magento root directory, you need to type:
php -f shell/log.php clean
The -days switch lets you set the days you want to save.
Manual cleaning with phpMyAdmin
If you want to clean all the tables, then this is the best option.
- Open the database in phpMyAdmin
- Select these tables:
- Click Empty from the With Selected list at the bottom of the page.
- Confirm Yes.
- Click the Structure tab and select the same tables.
- Click Optimise from the With Selected list at the bottom of the page.