This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

How to Clean Up and Optimize Your Magento Database Log For Faster Loading

Updated on  April 10, 2018

4 Min Read
Reading Time: 4 minutes

Every successful Ecommerce store depends on sizable databases to sell products and services online. Magento is a robust Ecommerce system that uses database logs like any other website. And to speed up your ecommerce store, it is essential to clean up the logs on a regular basis and optimize the store for faster loading. You can gain a significant boost in performance by cleaning your logs and optimize Magento store database regularly. It also assists in reducing the latency of query execution.

Magento Optimize Database

Magento stores that pile up a few GB’s of logs slow down the performance of the store and increase the usage of the deployed resources. It is time for you to learn how you can clean them up. In this article, I am going to share an easy to use way of how to clean your Magento database.

Magento Optimize Database Log

Magento maintains few tables for logging purposes. These tables create logs, for example, logs for which products have been compared. Magento has a mechanism for cleaning these logs regularly. However, this feature is disabled by default and most customers don’t turn it on. There are three ways to clean out these tables:

  • Log Cleaning in the Magento Admin,
  • Through log.php in the ../shell directory, and
  • Manually via phpMyAdmin or MySQL Manager.

These following tables are used and managed by Magento’s log cleaning functions:

  1. log_customer
  2. log_visitor
  3. log_visitor_info
  4. log_url
  5. log_url_info
  6. log_quote
  7. report_viewed_product_index
  8. report_compared_product_index
  9. report_event
  10. catalog_compare_item

Cleaning Logs via Magento Admin Panel

This method is straightforward and useful for non-technical store owners who do not want to work around directly with the Magento stores database. You can follow the following steps to clean database logs:

First Log in to your Magento Admin Panel.

  • Go to System > Configuration.

Magento Admin Panel

  • On the left side, under Advanced, click on System (Advanced > System).

Magento Admin Panel System

  • Under System, you see Log option.

Magento Admin Panel Log

  • Under “Log Cleaning,” change “Enable Log Cleaning” to YES and configure the Save Log for 15 days (or select the time you need to clean your log)
  • Click “Save Config.”

Cleaning Logs via MySQL Manager

If you are familiar with MySQL and queries, then this method is more useful and quicker than the default Magento log cleaning. This method also allows you to clean whatever log you like; you can even clean table which is not included in default Magento log cleaning. I will be using the Cloudways Platform to perform this.

  • In the Cloudways platform, go to Applications and under ACCESS DETAILS, tap LAUNCH DATABASE MANAGER button.

In the right side of your MySQL manager, click on the below-mentioned boxes for the following tables:

  1. dataflow_batch_export
  2. dataflow_batch_import
  3. log_customer
  4. log_quote
  5. log_summary
  6. log_summary_type
  7. log_url
  8. log_url_info
  9. log_visitor
  10. log_visitor_info
  11. log_visitor_online
  12. report_viewed_product_index
  13. report_compared_product_index
  14. report_event
  • Select all of the listed tables above in MySQL manager and click Truncate Button, Shown in image below:

Keep in mind that you just need to Truncate selected tables without dropping them. Be very careful when doing this.

Note: Some statistic data will be lost if you clean these log tables (like guest information, visit URL data…etc), if you think they are useless for you, then don’t hesitate to clear. If you are not sure what to erase, then save a backup in case things do not go as planned.

You should be careful when using these methods of clearing your logs. It is better to first take a backup of your Magento based ecommerce store before making any changes. With Cloudways, you have the option of taking a backup with just a single click. The Cloudways Magento Hosting platform is optimized to host Magento store of all sizes. Sign up now and see the power of managed Magento hosting sail you pass this (and many other) holiday seasons to come! And did I mention, You get a FREE trial for 3 days!

Share your opinion in the comment section. COMMENT NOW

Start Growing with Cloudways Today.

Our Clients Love us because we never compromise on these

About The Author

Fayyaz Khattak

Fayyaz is a Magento Community Manager at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at m.fayyaz@cloudways.com

Stay Connected:

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.