Magento, as is well known, places a high demand on web servers due to its extensive and secure modular structure. An eCommerce system must have a comprehensive tracking system that can track client activity, orders, and other pertinent data, and Magento has all of this functionality as well as storing all information in MySQL separate database tables in the form of logs. Magento features around ten log tables that must be optimized on a regular basis.
MySQL database optimization is the best way to organize your website in a better idea which can give a better experience to end user who is visiting and buying from your professionally designed eCommerce website.
I’ve covered everything relevant to Magento database log cleaning and optimisation in this post below, step by step: It is generally a good idea to backup your database before beginning the database optimisation procedure.
The following are the log tables controlled by the Magento system. It can keep track of customer activities, login information, customer product comparisons, visitor information, log URL, frequently seen items, and so on. There are three methods for optimizing and cleaning logs:
- Magento Default Log Cleaning Functionality
- Create Log Cleaning PHP script with cron Schedule
- Manually clear tables using phpMyAdmin.
Here are the tables which required optimization in Magento:
Execute below MySQL queries for the log cleaning of Magento database:
Magento Database Optimization and log cleaning via Magento Admin Default Functionality
- Log in to Magento Admin Panel
- Go to System>>Configuration
- From left sidebar click system under the advanced tab
- After clicking on the system menu, you will see a block opened from there select log clearing tab and set “Enable Log clearing ” options to “Yes” and set up your desired log cleaning period automatically.
- After the following step for just click on save config, and you are all set.
Optimize Magento Database using log_cleaning script
You can set manual cron script which can run periodically, mention shell command in it and put this script file in root folder if your Magento and set cron schedule on the web server to run this file for log cleaning.
You can specify your time on the cron so it will run as per your schedule rules:
Here is the command line –
php -f shell/log.php clean
Manually clean your Magento Database Log tables for optimization using phpMyAdmin
If you choose this route, make sure you understand database and phpMyAdmin structure since you will be doing operations with the database, which is the heart and soul of any programme. Before performing any cleanup, always backup the database. You may access the database using SSH command line or phpMyAdmin via your web hosting cPanel.
You must empty the tables mentioned below using the phpMyAdmin interface. click a table and then click “Empty” from the action menu at the bottom of the page. You will then see a confirmation screen; simply hit “yes” choices, and you are done.
To know more on optimization process just put your comment on this blog and I’ll provide you answers on it. Please refer this link to get platinum level Magento technical support services.
Feel free to contact us for any Magento Website Optimization services!
Fantastic blog post. Really helpful for me after Magento optimization with following this blog.
Thanks a lot Jiten. These steps work perfectly for me.
Great solution Jiten. Those tables are quite annoying and they actually take the site down if we don’t keep an eye on them. Cheers
Nice Solution but i want to optimize MySQL query which is generate in hourly like slow.log in /var/log/mysql/slow.log
Can we optimize the mysql query. Please provide me good suggestion.