Question

Well, this is a very rare problem, I know. Most of times we always try to speed up reindex process in Magento. What I am reporting here is the opposite

Sometimes (it does not happen always) reindexall process takes just a few minutes to reindex all the indexes. There are no errors in logs, so we have to assume process just ended ok. I have to point that it normally takes more than 45 minutes to reindex all indexes, as this concrete catalog has more than 100k skus

So, question is...

Any developer here has experienced an issue like this? In fact, the really useful question should be: where does Magento search for data needed to be reindexed every time we run a reindexall in Magento CE?

Looking at the DB I have noticed the index_event table does not seem to be updated for the last months. This is not the case for report_event table, which is updated

All indexes mode are "update on save"

UPDATE My (shameful) mistake, about index_event table. It has been updated, as well as report_event table

Was it helpful?

Solution

Index Management in Magento

The data that gets registered in the table "index_event" comes from different function from each of the files listed below for each Indexer. Let's pick 1 example say, app/code/core/Mage/Catalog/Model/Product/Indexer/Eav.php - This is responsible for the "Catalog Product Indexer (EAV mode)"

This contains 1 such function - _registerCatalogAttributeSaveEvent(Mage_Index_Model_Event $event) which registers the 1 part of data into the "index_event" table.

Other functions which are a part of the manipulated data inside the index_event table are as below (from the above mentioned file):

  • _registerCatalogProductSaveEvent
  • _registerCatalogProductDeleteEvent
  • _registerCatalogProductMassActionEvent
  • _registerEvent

In the function _registerEvent, if you see line no: 132 it calls out:

$event->addNewData('catalog_product_eav_reindex_all', true);

This is further checked in a condition in the same file Eav.php in line no: 292 in the function _processEvent which calls out for the function:

$this->reindexAll();

This function can be found in app/code/core/Mage/Index/Model/Indexer/Abstract.php

Furthermore, here is where the CATALOG DATA/Tables are identified or comes from (I am posting it for only CATALOG):

Catalog Data/Tables are here (which are used while reindexing): app/code/core/Mage/CatalogIndex/Model/Resource/Data/Abstract.php

For the rest of the INDEXES, please read or see below:

**#1 index_event is updated with the mode for each indexer set as "Update on Save" **

Screenshot here (from what I have tried in my machines):

enter image description here

Note: I have not run a reindexall from SHELL. This is purely after saving a product from ADMIN panel

#2 Indexers for each module like Catalog, CatalogSearch etc

We normally see indexers with names as below: Catalog Product Flat Catalog Category Flat Catalog Search Product URL Rewrites Category URL Rewrites .....

Check the folder "INDEXER" under:

app/code/core/Mage/CatalogSearch/Model/Indexer

Inside this folder the files differ. See below:

Product Flat Data / Product Attributes

app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php (This is used only when the Catalog Flat mode is enabled)

app/code/core/Mage/Catalog/Model/Product/Indexer/Eav.php

Category Flat Data

app/code/core/Mage/Catalog/Model/Category/Indexer/Flat.php (This is used only when the Catalog Flat mode is enabled)

If the flat tables are not enabled, then below files can be checked:

app/code/core/Mage/CatalogIndex/Model/Indexer/Abstract.php app/code/core/Mage/CatalogIndex/Model/Indexer/Eav.php app/code/core/Mage/CatalogIndex/Model/Indexer/Interface.php app/code/core/Mage/CatalogIndex/Model/Indexer/Minimalprice.php app/code/core/Mage/CatalogIndex/Model/Indexer/Price.php app/code/core/Mage/CatalogIndex/Model/Indexer/Tierprice.php

Category Products Index

app/code/core/Mage/Catalog/Model/Category/Indexer/Product.php

Product Prices Index

app/code/core/Mage/Catalog/Model/Product/Indexer/Price.php

Catalog URL Rewrites

app/code/core/Mage/Catalog/Model/Indexer/Url.php

Stock Status

app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php

Catalog Search Index

app/code/core/Mage/CatalogSearch/Model/Indexer/Fulltext.php

Tag Aggregation

app/code/core/Mage/Tag/Model/Indexer/Summary.php

All the above files contain a function named:

matchEvent(Mage_Index_Model_Event $event)

This function is where the following happens:

  1. Table is picked
  2. Index tables with _TMP are created
  3. Data is fetched (Database and tables are locked prior to doing this in another function)
  4. Data is manipulated via various Events (Save, Update, Delete etc)

That's how indexing works.

Hope this helps!

Happy Coding...

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top