I have some queries for Magento Indexing Process:
- First of all, why Magento does not perform the indexing process programmatically, after each Product or any of its Attribute(s) are newly added / modified? Why Admin(s) require to do the indexing, when the indexing processes are very much important & can be done programmatically?
- In each indexing process, are all the products indexed (including those which have been indexed already), when the “Reindex Data” link is clicked, or only the non-indexed products are indexed?
- If I want to view / debug the time taken for each indexing process, then what & how will I need to do?
Three part answer, so this should be worth triple points, right? 🙂
1) Probably because indexing tends to be a computationally intensive task, so rather than slow the site whenever a product is saved (usually during business hours), an Administrator can choose a low-load period, or schedule via cron for the indexing to occur at a typically low-load time.
2) All products are re-indexed. If you look in Mage_CatalogIndex_Model_Indexer::plainReindex(), you will see that it performs a
clearto delete all index data before getting all active products to index.where the _walkCollection method creates the index for each product.
3) You could turn on the Profiler. There are some great blog posts on how to use that. You could wrap the key code in
Mage_CatalogIndex_Model_IndexerwithVarien_Profiler::start('Indexer')etc to check the time taken.