Magento 2 Database Log Cleaning

Frustrated by the ridiculous database log management (or the lack thereof) in Magento 2? Us too. We keep hoping that with each iteration, 2.1, 2.2, 2.3 they would finally consider that actions that took place four years ago don’t need to be cluttering our databases. I digress. If you’re looking for a quick sql solution to clean up millions of database rows in your Magento installation, look no further:

SET foreign_key_checks = 0;
TRUNCATE customer_log;
TRUNCATE customer_visitor;
TRUNCATE report_compared_product_index;
TRUNCATE report_event;
TRUNCATE report_viewed_product_aggregated_daily;
TRUNCATE report_viewed_product_aggregated_monthly;
TRUNCATE report_viewed_product_aggregated_yearly;
TRUNCATE report_viewed_product_index;
TRUNCATE product_alert_stock;
TRUNCATE search_query;
TRUNCATE catalogsearch_fulltext_scope1;
TRUNCATE sales_bestsellers_aggregated_yearly;
TRUNCATE sales_bestsellers_aggregated_monthly;
TRUNCATE sales_bestsellers_aggregated_daily;
SET foreign_key_checks = 1;

Leave a Reply

Will not be published

Satisfaction Guaranteed

We stand by our work

We know that our work produces real results. Whether it be increased visits, leads, conversions, or sales... Saderra has the track record of success with some of the world's largest and most notable brands. At the start of each project we will work with you to create a thorough checklist of achievable goals and realistic expectations, including a full list of deliverables. Your project isn't complete and our final invoice for the work isn't due until those goals and deliverables are met and provided. Saderra believes you should get what you pay for, and we won't stop working until you do.