4

Generally Magento's index can be updated in 3 ways (depending on usage and configuration):

  1. "On Save"
  2. "By Schedule"
  3. Using indexer:reindex command

This is what I can gather from the description in the official documentation for each of these ways:

  1. The index will be updated immediately when e.g. a product is changed in the back end and saved.
  2. According to the graphic of the Indexing types in the documentation, when editing and saving a product, entries are made in a changelog table (via MySQL triggers). Magento's cron:run command (which would be set up to run every minute by default) will then index those changed products.
  3. This command will update the complete index.

Just for clarification I want to know if the following is true for each of the 3 ways of updating the index:

  1. The index is updated "On Save" only for the affected data (i.e. the changed product), not the whole index (which would take very long).
  2. The index is only updated for the changed products (should be obvious).
  3. The index is updated for all products, regardless of whether they have been changed or not.

And to clarify further: is it true, that the only way to update the index only for changed products is via "On Save" or via "By Schedule" plus cron:run?

2

Reindex On Save - The Reindex will take place in real time when a change is saved in backend. It will be fine for small websites with a few admin users.

Reindex On Schedule - Reindex will be scheduled to take place via cronjobs accordingly. It will be suitable for stores with huge data and many admin users. If you have set reindex to occur every one hour, if you are making any change in the backend your change will be applied in the frontend within a maximum period of 1 hour.

indexer:reindex - When you want to reindex all indexers we can use this command.Ex: If a reindex gets locked we can reset the indexer and use this command to reindex all indexers.

Both Reindex On Save and Reindex On Schedule can be used to update the index of changes stores. You can choose between the two based on your store size and frequency of changes made to products.

1

Since posting the question, I found a few articles that explain Magento's indexing mechanic in a little more detail. One of the more detailed one is https://www.bigbridge.nl/blog/essential-magento-2-partial-reindexing/

This essentially confirms my questions:

  • regardless of how you update a product (back end, REST API or direct SQL queries for example), the indexer_update_all_views cron job will update the index for the changed products (when set to "By Schedule").
  • indexer:reindex will always update the complete index, not just for the changed entities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.