3

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

2
  • This is the concrete question: 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? Commented Feb 3, 2016 at 10:46
  • anyone could ans my question please? magento.stackexchange.com/questions/101137/… Commented Feb 10, 2016 at 6:49

1 Answer 1

3
+100

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...

6
  • That's a very complete answer. Thanks for that! But I was asking (my mistake, maybe it's not clear enough) for the concrete methods in the different Magento objects which register data in index_event table. If you update your post with that info then you'll get the points Commented Feb 4, 2016 at 9:46
  • The above files which I have mentioned contain the exact functions which registers data in "index_event" table. This data gets manipulated and the function that does that can be found in the file app/code/core/Mage/Index/Model/Event.php. To add on, let's pick Catalog/Product/Indexer/Eav.php you can find the function - _registerCatalogAttributeSaveEvent(Mage_Index_Model_Event $event) which ADDS data to the "index_event" table. Let me know if this helps.
    – Shivani
    Commented Feb 4, 2016 at 9:55
  • The above mentioned is 1 such function which inserts/registers 1 part of data in the index_event table.
    – Shivani
    Commented Feb 4, 2016 at 10:03
  • Well, that's a beginning. Points for you Commented Feb 4, 2016 at 11:13
  • anyone could ans my question please? magento.stackexchange.com/questions/101137/… Commented Feb 10, 2016 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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