Skip to main content

Magento2 Indexing Change Mode programmatically

Magento2 Indexing Mode 

You can set the mode via command line

php bin/magento indexer:set-mode {realtime|schedule} [indexer-name]

“realtime” is equal to “Update on Save” and “schedule” is equal to “Update by Schedule”.


Magento2 Indexing overview

Indexing is how Magento transforms data such as products and categories, to improve the performance of your storefront. As data changes, the transformed data must be updated or reindexed. Magento has a very sophisticated architecture that stores lots of merchant data (including catalog data, prices, users, and stores) in many database tables. To optimize storefront performance, Magento accumulates data into special tables using indexers.


Magento2 Indexing modes

Reindexing can be performed in two modes:

  • Update on Save - index tables are updated immediately after the dictionary data is changed.
    Update on Save indexers must use custom code (plugins, events or any other working approach) in order to trigger reindexing when entities are saved/deleted etc.
  • Update by Schedule - index tables are updated by cron job according to the configured schedule.
    Update by Schedule does not support the customer_grid indexer. You must either use Update on Save or reindex the customer grid manually (bin/magento indexer:reindex customer_grid). 


Magento2 Indexing types

Each index can perform the following types of reindex operations:

  • Full reindex, which means rebuilding all the indexing-related database tables
    Full reindexing can be caused by a variety of things, including creating a new web store or new customer group.
    You can optionally fully reindex at any time using the command line.
  • Partial reindex, which means rebuilding the database tables only for the things that changed (like changing a single product attribute or price)


The type of reindex performed in each particular case depends on the type of changes made in the dictionary or in the system. This dependency is specific for each indexer.



Indexing overview | Magento 2 Developer Documentation