October 29, 2024

How to Reindex Magento 2? Aspects of Magento Index Management

Nadya Bakhur

Researcher, Technical Writer

Magento (Adobe Commerce)

How to reindex Magento 2?

Nadya Bakhur

Researcher, Technical Writer

Magento (Adobe Commerce)

How to reindex Magento 2?

Magento is a powerful and complex system. It allows for working with large data volumes. However, if the database is overloaded with tons of records, Magento becomes heavy and slow.

In order to resolve this problem in Magento, you need to use indexes.

In our article, you’ll find out the Magento indexer meaning and useful tips on how to avoid an issue which is referred to as ‘Magento 2 admin slow down’.  

Introduction: What Is Indexer in Magento?

Magento 2 has a rather complex system for storing products, categories, and related data such as product prices, product group prices, and discounts. To speed up the retrieval of this data in Magento administration, we use index tables. Without indexing, all of this would have to be calculated on the fly. This, in its turn, would have a significant impact on performance.

By the way, we have already discovered various ways to speed up Magento. Discover them in this article and this mini-guide.

Index tables are a dataset optimized for fast retrieval. This approach allows you to make all the necessary calculations in advance. For example, in the case of providing discounts through an online store, you can use your already processed data instead of having it processed for each request separately.

Indexers are responsible for creating indexes. These are classes responsible for processing the data and saving it in the desired format.

Thus, we can say that Magento 2 index is a table with a fetch-optimized dataset. Magento 2 indexer in its turn is a class that optimizes data and puts it into the index table.

If you change any product prices Magento should reindex all prices so that the changes would go displayed on your website. If you don’t do indexing, Magento must calculate all changes for each page on the move according to basket pricing rules, group prices, discounts, differential pricing, etc.

Long page loading often leads to a purchase refusal. Magento reindex helps to avoid long page loading. How To Reindex Magento 2? A Few Ways To Follow

Extension for Custom Indexing

Reindexing Magento 2, you can follow one of the following options:

  • Complete reindex, necessary to recalculate all the index data;
  • Partial reindex, to reindex Magento specific values.

Below we will overview both ways to reindex Magento 2 stores, so stay tuned!

Complete reindex

To start a complete reindex, the indexer_reindex_all_invalid task is launched:

<!-- vendor/magento/module-indexer/etc/crontab.xml -->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">

<group id="index">

<job name="indexer_reindex_all_invalid" instance="Magento\Indexer\Cron\ReindexAllInvalid" method="execute">

<schedule>* * * * *</schedule></job>  </group> </config>

One of the ways to start reindexing Magento store is to execute a console command specifying a particular indexer:

php bin/magento indexer:reindex catalog_product_flat

You can also rebuild all indexes from the console at once. To do that, you just need to omit the name of the indexer:

php bin/magento indexer:reindex

As a result, you will receive a message telling you that all indexes have been rebuilt:

Design Config Grid index has been rebuilt successfully in <time>

Customer Grid index has been rebuilt successfully in <time>

Category Products index has been rebuilt successfully in <time>

Product Categories index has been rebuilt successfully in <time>

Catalog Rule Product index has been rebuilt successfully in <time>

Product EAV index has been rebuilt successfully in <time>

Inventory index has been rebuilt successfully in <time>

Catalog Product Rule index has been rebuilt successfully in <time>

Stock index has been rebuilt successfully in <time>

Product Price index has been rebuilt successfully in <time>

Catalog Search index has been rebuilt successfully in <time>

In the console, the status of indexes will look like this:

bin/magento indexer:status

The indexers’ ID from the console will look the following way:

bin/magento indexer:info

Let’s summarize the commands: php bin / magento <command>

indexer: status = will show which indexes need updating;

indexer: info = will show the id of all indexers;

indexer: reindex = reindex all indexes (all indexers will run in turn);

indexer: reindex <indexer id> = start specific indexer.

Partial reindex

Partial Magento 2 reindex means that only the selected items will be reindexed. For example, you changed the price of a product in the admin panel, and you need to update all related records in the index tables where this product is mentioned.

Partial Magento 2 reindex can be of 2 types:

  1. Update on Save: the data is updated when changes are saved;
  2. Update by Schedule: the changed data is updated according to the schedule.

For each of the indexes, you can set its own type of update. For example, the price index should be updated “on schedule”, and the category index should be updated “at the time of saving”. You can change these settings in the admin panel: Magento Admin > System > Tools > Index Management, then check the necessary indexes with the checkboxes and select the desired item in the “Actions” drop-down list:

Magento Index Management

The main difference between the two methods is your website performance during the reindexing.

Update on Save is used if during saving there will be no need to update a large number of elements. For example, if you have 3 categories and 50 products, then you can safely use this method. In addition, this method allows you to almost instantly synchronize changes with the storefront.

Update on Schedule is used when you have a huge number of products or you need to reindex many records. It works like this: the id of the changed records are accumulated in a separate table with the _cl postfix, the indexing process is started according to the schedule, which updates these records one by one.

Magento development requires knowledge. And it’s appreciated when you can get working advice from experienced Magento developers. NEKLO’s certified Magento specialists provide you with expert opinion on what operating system to select for Magento. Don’t miss it!

Magento Index Management: How To Make It Easier?

In Magento 1, you start indexing right from the admin panel. If your store is based on Magento 2, reindexing from admin is not possible. In this case, you should use an extension or you can use the Magento 2 reindex command line to trigger reindexing.

Magento Reindex

Reindexing through the admin panel

Magento Marketplace offers a rich variety of extensions for custom indexing. At NEKLO custom Magento development, we also have built a powerful tool to make Magento 2 reindex easy and headache-free.

Our Advanced Reindexer Extension allows you to start indexing right from the admin panel.

To trigger reindexing, do the following:

  • Log in to your Magento admin panel;
  • Go to System > Tools > Index Management;
  • Select the categories you want to reindex;
  • Select “Update Now” from the Action drop-down list there;
  • Click “Submit”.

NEKLO Advanced Reindexer provides you with the opportunity to schedule indexing. However, if you don’t want to use an extension you can trigger indexing from the Magento reindex command line.

Conclusion

Magento at first glance has a rather complex architecture. However, if you take time to learn how it is arranged, it becomes clear that all this complexity is a necessity for building elegant solutions for complex ecommerce needs.

At NEKLO, we specialize in helping Magento online store owners. In case you have a question or want to build a solution, just contact us through the form on our website.

Our experts will find the right, custom approach.