The exact way we optimize Magento database

Table of Contents

It’s quite easy to build and manage an online business store with e-commerce platforms like Magento. And, website speed becomes a key factor for success.

Luckily, Magento provide different ways to enhance the performance and efficiency of Magento website. A popular one is to optimize Magento database.

That’s why, we often get requests from our customers to “optimize Magento database” as part of our Server Management Services.

Today, we’ll see how our Support Engineers optimize database in Magento based on the frequent request from our clients.



Reasons on why to optimize the database?

Like any dynamic web application, Magento also depends heavily on the database.

When it comes to large databases, one of the most common cause is its impact on site performance.

However, it’s good to optimize Magento database due to the following reasons including:

–  Clean database log tables.

–  Manage the database size.

–  Improve site performance.

–  Enhance access speed to retrieve data.

From our experience in managing websites, we always see that Magento website with optimized database always perform better.


Top 3 ways to optimize Magento database

Now, let’s see how we execute the steps to optimize Magento database.

Recently one of our customers approached us claiming that he uses Magento version and have 30000 products in his store so that his database size raises approximately to 3 GB. In order to improve site performance, he wanted to optimize his database.

There are different ways to optimize Magento database. In any case, our Support Team always takes a website and database backup, This comes handy in case of any failures.

Let’s see how our Technical Engineers took the necessary steps to optimize database one by one.


1. Log cleaning from the Admin Panel

The first step was to do log cleaning. To optimize log settings for Magento store, we follow the below steps.

1. First, we log in to Magento Admin Panel and select System > Configuration.

2. Then we click System under the Advanced menu.

3. And under the System panel > Log, we select Yes in Enable Log Cleaning field.

4. Next, we enter value 15 in the Save Log Days field. It saves log file for every 15 days.

5. Finally, click Save Config.


2. Using log_cleaning script

Similarly, we often set manual cron script that runs periodically for log cleaning.

For this, we took the following steps.

1. First, we log in to the account using SSH.

2. Then, change the directory in which Magento is installed.

cd ~/public_html/shell

3. We execute the following command to clean log files.

php -f log.php clean --days 10

Thus, it keeps log information in the database and deletes the rest. We also suggest to set this a cron job so that server executes this at regular intervals.


3. Manual cleaning with phpMyAdmin

Likewise, this is also one of the most efficient ways to clean log files.

This procedure truncates the data inside tables, thus decreasing database size and reducing query times.

To do this we follow the necessary steps below.

1. First, we log in to the control panel and open the database in phpMyAdmin.

2. In the right menu, we select the checkbox for the following tables:


3. At the bottom, select Empty under With Selected list.

4. Next, click Yes. This truncates all selected tables.

5. Then we click the Structure tab and repeat step 2.

6. Finally, under the With Selected list, choose Optimize.

That fixes the problem and the customer’s database size reduced. As a result, his site performance also increased.


[Having problems to optimize Magento database? We’ll fix it for you.]



In short, Magento logs several items such as customer details, quote information, etc. in the database. Over a period of time, these logs become larger and affect database performance. So, its really important and a must to optimize Magento database. Today, we saw how our Support Engineers optimize Magento database for maximum speed and performance.

Leave a Comment

Your email address will not be published. Required fields are marked *

Social Share


Cheapest Web Hosting

Fasters Web Hosting Promo
Scroll to Top

Launch your Website at RS599

Create a professional website yourself with our domain hosting combo. Get Extra benefits at this Year end Sale with 10% OFF and Enjoy Amazing Deels on Shared Hosting!

Starting at Only RS599/Year

Year End Sale


Use Code STARTBIZ at Checkout.

Create an earning opportunity with A Web Hosting Business

Become reseller and start reselling domains, web hosting, ssl certificates and More.

45% OFF

Starting at RS399/Month


Use coupon: at the checkout.