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):
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:
- Table is picked
- Index tables with _TMP are created
- Data is fetched (Database and tables are locked prior to doing this in another function)
- Data is manipulated via various Events (Save, Update, Delete etc)
That's how indexing works.
Hope this helps!
Happy Coding...