6

If exported current database as an SQL file size is over 600Mb. Most of which are logs. My question is can cleaning up logs from the database be a good practice to speed up a Magento website?

1

Magento maintains several tables for logging.These tables log things such as customer and visitor accesses and which products have been compared and which are viewed.Magento has a mechanism for cleaning these logs regularly, but unfortunately this feature is disabled by default and most customers do not turn it on.Please follow the steps to clean out the log tables

  1. Open the database in phpMyAdmin via Control Panel.

  2. In the right frame, select the check box for the following tables:

    dataflow_batch_export
    dataflow_batch_import
    log_customer
    log_quote
    log_summary
    log_summary_type
    log_url
    log_url_info
    log_visitor
    log_visitor_info
    log_visitor_online
    report_viewed_product_index
    report_compared_product_index
    report_event
    
  3. At the bottom of the page, click the drop-down box With Selected and select Empty.

  4. A confirmation screen will appear. Click Yes. This will truncate all of the selected tables.

    Keep in mind that we are here to empty (Truncate) selected tables are not drop them. Be very careful when you do this.

  • Thanks for the expanded answer and a provided link. Surely comes in handy – AntK Sep 29 '15 at 11:16
  • 2
    No. The correct answer is to enable the feature, not just throw away all the data. – user207421 Sep 29 '15 at 22:16
  • When you say 'enable the feature' which feature exactly do you refer to @EJP – AntK Oct 1 '15 at 5:45
  • 1
    -1 - You mention that Magento has a built-in cleaning feature--then you don't show how to use it--very misleading. – STW Oct 1 '15 at 22:58
  • The link has become broken... – 7ochem Jun 22 '18 at 8:47
7

Yes, you can configure your settings in Admin to automatically clean up logs.

System > Configuration > Advanced > System > Log Cleaning

You need to setup the Cron job for this on server.

  • +1 - this is the best answer. Configure the site to store a reasonable duration of logs and the cron will clean up log entries as they pass their expiration – STW Oct 1 '15 at 22:57
5

If you don't need the data at all, you can think about changing the database engine from InnoDB to BLACKHOLE.

  • 7
    or just disable logging events, no need to perform insert operations at all – Pavel Novitsky Sep 29 '15 at 11:13
1

I can't see any issues with it, I have been doing this for the past few years with no problems, also you can turn the log cleaning via cron job

Try this:

SET foreign_key_checks = 0;

TRUNCATE mage_core_cache;
TRUNCATE mage_core_cache_option;
TRUNCATE mage_core_cache_tag;
TRUNCATE mage_core_session;

TRUNCATE mage_dataflow_batch_export;
TRUNCATE mage_dataflow_batch_import;
TRUNCATE mage_log_customer;
TRUNCATE mage_log_quote;
TRUNCATE mage_log_summary;
TRUNCATE mage_log_summary_type;
TRUNCATE mage_log_url;
TRUNCATE mage_log_url_info;
TRUNCATE mage_log_visitor;
TRUNCATE mage_log_visitor_info;
TRUNCATE mage_log_visitor_online;
TRUNCATE mage_report_viewed_product_index;
TRUNCATE mage_report_compared_product_index;
TRUNCATE mage_report_event;
TRUNCATE mage_index_event;
TRUNCATE mage_index_process_event;
TRUNCATE mage_catalog_compare_item;
SET foreign_key_checks = 1;

Sure you can remove mage_ if you don't have it in you table name or replace it with whatever you have.

0

Cleaning log is good idea for health of database.As per as magento, log table are store data about customer/visitor visaed urls and times etc.

If it not important for you then you can do log cleaning

  • You can still track more popular pages/products/categories etc via google analytics. So cleaning logs should only make sense – AntK Sep 29 '15 at 11:13
  • yes. as you use ga then you can do log clean... – Amit Bera Sep 29 '15 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.