Everyone who has worked with Magento for a time knows that Magento uses indexers to achieve higher performance than it might otherwise achieve when dealing with certain complex data types. A list of these indexers can be easily found by looking at the output of
bin/magento indexer:status on the CLI. These indexers usually support both synchronous (Update on Save, also known as
realtime) and asynchronous (Update on Schedule, also known as
schedule) modes. In a production system, generally these indexers should be configured to run asynchronously (in spite of the default being Update on Save, for synchronous mode).
But there are more indexers than just what meets the eye! In order to enhance performance of order management functionality, Magento has a series of grid tables:
sales_shipment_grid. These tables are used when viewing lists of orders, invoices, etc in the Magento backend.
Normally these indexes are kept up-to-date in realtime whenever an order management entity is created or updated, but occassionaly, there are times where these tables can turn up empty, and when they do the hidden indexers are your friend as they can be easily used to rebuild the contents of these grid tables.
These indexers can be enabled via the
dev/grid/async_indexing setting (also available under Stores -> Configuration -> Advanced -> Developer -> Grid Settings in the Magento admin). When this setting is enabled, cron jobs will become activated to keep these tables up-to-date in the background (meaning there could be latency between the time a customer places an order and when the order shows up in the admin, especially on high volume sites).
But it gets better! Enabling the async index, and then disabling it triggers a rebuild as disabling the setting dispatches an event for an observer that rebuilds each of the grids, allowing one to easily rebuild them ad-hoc without waiting on a cron to run (or where cron has not been setup yet) before disabling the async indexers to return again to default behaviour. This is done of course to be sure they are fully up-to-date when the aysnc mode is turned off, but comes in handy when these tables turn up empty after a data migration and you need to refil them so admin users can see old order data.
Here’s how to rebuild the grids from the command line, just be warned that second command will take a bit longer than the frist since it’s repopulating the grid tables:
bin/magento config:set dev/grid/async_indexing 1 bin/magento config:set dev/grid/async_indexing 0