Table of Contents
Managing product stock, updating price lists, and saving configuration changes are routine tasks for Magento store owners. However, these activities can lead to performance issues when coupled with constant caching and index rebuilding. This article will guide you through optimizing Magento indexing process to enhance your store’s performance.
What is Magento Indexing?
Indexing is how Magento processes and organizes data (like products and categories) to make a storefront load faster. When one updates data, such as changing a product’s price, Magento needs to reindex this information so the changes show up on a website.
Without indexing, Magento would have to calculate things like product prices, discounts, and special settings every time a customer views a page. This would slow down your store and could lead to unhappy customers leaving their carts behind.
Here are a few key terms to understand:
- Dictionary: This is the raw data you enter into the system, like product details or prices. It’s organized in a way that makes it easy to update.
- Index: This is a processed version of the raw data, optimized for quick searches and display on your storefront. Magento uses algorithms to turn dictionary data into indexes.
- Indexer: This is a tool that creates and updates indexes based on the dictionary data.
You may read more about indexing here.
Understanding Magento Indexing Modes
Magento offers 2 indexing modes to manage data updates:
- Update on Save:
- This mode triggers specific indexing whenever you save a product, attribute, or category.
- While it ensures real-time updates, it can consume significant server resources, slowing down your website’s performance.
- Custom code (like plugins or events) is needed to trigger reindexing when entities are saved, deleted, or modified.
- Update by Schedule:
- This mode performs tasks via a cron job at predetermined times.
- Ideal for low-traffic periods, this mode reduces the load on a server, enhancing overall performance.
Note: The customer_grid indexer is not supported in “Update by Schedule” mode. You must either use “Update on Save” or reindex the customer_grid manually using the command:
php bin/magento indexer:reindex customer_gridChecking Your Current Magento Indexing Mode
To identify the current indexing mode you have, you may use the following command:
php bin/magento indexer:show-modeSwitching Indexing Modes
You can easily switch between Magento indexing modes using the following command lines:
- To set the mode to “Update by Schedule,” run:
php bin/magento indexer:set-mode schedule- To return to “Update on Save,” run:
php bin/magento indexer:set-mode realtimeReindexing through the Command line:
You can reindex using the below reindex command (you need to go to the Magento root folder and then run the below command line):
php bin/magento indexer:reindexRunning Indexing from Magento Admin
You can also manage indexing directly from the Magento Admin panel:
- Log in to your Magento Admin dashboard.
- Navigate to System > Tools > Index Management.
- Select all indexers and choose “Update by Schedule” from the Actions dropdown menu.
Configuring Cron Jobs for Scheduled Tasks
Setting your indexer mode to “Update by Schedule” allows you to execute tasks during low-traffic periods, hence optimizing Magento indexing. Here’s how to configure cron jobs for indexing:
- Log in to your Magento Backend.
- Go to Store > Settings > Configuration.
- Navigate to Advanced > System > Cron (Scheduled Tasks).
- Expand the section titled “Cron configuration options for group: index”.
- Set the desired configuration options.
Benefits of “Update by Schedule”
- Enhanced Performance: Reduces server load by running resource-intensive tasks during off-peak hours.
- Efficient Resource Utilization: Prevents real-time indexing from impacting customer experience.
- Customizable Scheduling: Allows flexibility in setting task execution times to suit your store’s needs.
Conclusion
Using Magento’s “Update by Schedule” mode helps store owners keep their operations running smoothly while improving site performance. By setting up these configurations, you can make your backend work efficiently and provide a better shopping experience for your customers.