Clear log table & speedup the website speed as well as free up the server space

blog-clear-log-tables-magento1

Magento keep the log file internally to track the visitor, cart, customer, report etc. Once the website get older the logs get larger and that make slow down the website speed and consume the server space

In this article i will guide you how to prevent large log data. That will be beneficial for your website speed and server space

There is two way to achieve the target:
1) Manual process: Go to the database and truncate the below tables time to time:
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

2) Clear the log table using cronjobs: This process is safe and easy to implement. Create a php script, using mysql query truncate data from database table.add This php script at cronjob as per as your requirement.
getConnection(‘core_write’);
$query1 = “truncate table dataflow_batch_export”;
$query2 = “truncate table dataflow_batch_import”;
$query3 = “truncate table log_customer”;
$query = “truncate table log_quote”;
$query4 = “truncate table log_summary”;
$query5 = “truncate table log_summary_type”;
$query6 = “truncate table log_url”;
$query7 = “truncate table log_url_info”;
$query8 = “truncate table log_visitor”;
$query9 = “truncate table log_visitor_info”;
$query10 = “truncate table log_visitor_online”;
$query11 = “truncate table report_viewed_product_index”;
$query12 = “truncate table report_compared_product_index”;
$query13 = “truncate table report_event”;

$writeConnection->query($query1);
$writeConnection->query($query2);
$writeConnection->query($query3);
$writeConnection->query($query4);
$writeConnection->query($query5);
$writeConnection->query($query6);
$writeConnection->query($query7);
$writeConnection->query($query8);
$writeConnection->query($query9);
$writeConnection->query($query10);
$writeConnection->query($query11);
$writeConnection->query($query12);
$writeConnection->query($query13);
$writeConnection->query($query13);
?>
Add the php script in cronjob after 15-30 days. so the log file will clear time to time and website speed didn’t get slow down, also it save your server space.

Leave a Reply

Your email address will not be published.