Table of Content
- Clean up Magento Database Logs
- Optimise Magento Database Logs
- Reduce Database Queries by Switching to Flat Catalogue
- Update Database Version
- Use & set Latest Elasticsearch
The sizable databases that enable you to sell products and services online play a part in the success of your eCommerce company. The Magento eCommerce website will also use these database logs. As your Magento store accumulates a few gigabytes of logs, its speed will suffer, and the deployed resources will increase consumption.
As a result, you must keep these logs clean and optimise the store for speedier loading. It improves speed, but it also helps to reduce query execution delay.
In this article, I will teach you how to clean and optimise your Magento database quickly and easily.
Clean up Magento Database Logs
Magento comes with a PHP script that can be launched from the command line to check the state of Magento’s logs and manually clean them. Follow these steps to accomplish this:
- Use SSH to access your account.
- Type the following command at the command prompt:
Note: This command assumes that Magento was installed in the document root (public_html) directory. If Magento was installed in a subdirectory, navigate to that directory instead. Type cd /public_html/Magento/shell if you installed Magento in the public html/Magento directory.
- Type the following command to see the size of each log table in the database:
php -f log.php status
- Type the following command to clean the log tables. Replace X with the number of days in the log tables that you want to save:
php -f log.php clean –days X
If you run php -f log.php clean—days ten on Magento, it will keep the last ten days of log data in the database and erase the rest.
Optimise Magento Database Logs
Follow these procedures to enhance your Magento store’s log settings:
- Use your administrator account to access Magento.
- Click System, then Configuration, from the top menu bar.
- Scroll down the page in the Configuration box on the left side, and then pick System under Advanced.
- Then select Log Cleaning. The log settings are displayed.
- Type 60 in the Save Log Days text box.
Note: If you have a busy site or a large business, you might wish to save logs for even fewer days (such as 30 or 15) to keep the database size under control.
- Select Yes in the Enable Log Cleaning list box.
- Choose when Magento cleans the logs in the Start Time text boxes.
- Make sure the Daily frequency list box is checked.
- The following options are available:
- You can select an email address in the Error Email Recipient text box to receive messages if any errors occur during log cleansing.
- You can select the contact name that displays as the sender for any error messages in the Error Email Sender list box.
- Select the Log Cleaning Warnings default template from the Error Email Template dropdown box.
- Save the configuration. The changed settings go into effect right away.
Reduce Database Queries by Switching to Flat Catalogue
You can minimise the database’s loading time by converting to a flat catalogue. The system will then swiftly execute the most commonly utilised database queries.
The Flat Catalogue option in Magento is simple to enable. It will come in handy if you have an extensive database in your Magento store. The more significant its magnitude, the greater its impact.
- Log in to your Magento Admin Panel first.
- Go to Stores > Configuration > Catalogue to get started.
- Use Flat Catalogue Category and Use Flat Catalogue Product must be set to Yes.
- Select the Save option.
Update Database Version
To increase efficiency, security, and bug fixes. I strongly advise developers to keep databases (MySQL, MariaDB, or Percona) up to date for reading and writing accessibility, increased speed, improved algorithms, and more.
Use & Set Latest Elasticsearch
Log in to your Magento Admin Panel to begin setting up and using Elasticsearch on your store.
Navigate to the Store, then to Configuration. Expand the Catalog section by selecting it. There is an Elastic Search 7 option available. Select it and save it.
Clean your Magento database logs regularly to improve speed and performance, but do so with caution. Before making any changes, make a backup of your Magento-based eCommerce store. You may establish a backup with a single click with various Magento hosting providers.