kirkmadera
kirkmadera

Reputation: 575

How do I run a partial reindex in Magento 1.13?

I would like to be able to set all indexes to "Update on schedule" and then have them all update automatically like Magento says they should in the background. The problem is, this doesn't happen. There is no cron job that automatically reindexes (See this related question).

So, if I have to create my own cron job, how do I do this exactly in an efficient way? I don't want to run "php shell/indexer.php reindexall". That does full rebuilds of index tables. Sure, I could do that nightly, but that means that no changes will be reflected on the frontend until the next day. That's not an acceptable solution. If I run full reindexes throughout the day, I end up with the same problem that I have right now - table locks and slowness due to reindexing while people are working in the admin.

Magento's new "partial reindexing" should fix this right?

This is my understanding of how it works:

  1. I edit an entity that has a related index (e.g. A product).
  2. A database trigger adds a record to related change log tables.
  3. Some process later reads the change log tables and reindexes these specific entities

Concrete example

  1. I update a value in "catalog_product_entity_varchar".
  2. The database trigger "trg_catalog_product_entity_varchar_after_update" flags this product as changed by inserting a new version into "catalog_product_flat_cl" and "catalogsearch_fulltext_cl".
  3. A partial reindex process reads these change log tables and reindexes only the products mention to "catalog_product_flat" and "catalogsearch_fulltext" respectively.

If this were the case, the reindexing process would be minimal and could be run often. Even every minute to where indexing becomes almost unnoticeable to admin users. (I say every minute, because Magento tells us this is possible)

In this release, however, the flat catalog is updated for you — either every minute, or according to your Magento cron job.

Where is this mystical partial reindex? How do I call it instead of reindexing everything?

Is there a reindexPartial()?

Underpants + ? = profit

Upvotes: 3

Views: 2646

Answers (2)

kirkmadera
kirkmadera

Reputation: 575

The enterprise_refresh_index cron job appears to run this. It runs every time the Magento cron runs. See Enterprise_Index_Model_Observer::refreshIndex().

This is not intended to run manually because of the need to establish a lock file. It is easiest just to run the cron.php file if you need a manual reindex.

I believe I just have a project specific issue with this not running.

Upvotes: 2

Axel
Axel

Reputation: 10772

The partial reindexing is executed through the cron job operator built into Magento. You do not need to run the actual indexer.php file. Instead, you must setup Magento's built in Cron scheduler based on the documentation.

Documentation: http://www.magentocommerce.com/wiki/groups/227/setting_up_magento_in_cron

You simply execute the cron.php file, which will in turn call the partial reindexing process.

php5-cli -f /home/USERNAME/public_html/cron.php

How it works:

  1. A change to the an entity is made and is flagged to be reindex.
  2. A cronjob executes the cron.php file
  3. Magento checks to see which cron tasks it will run, and runs the partial reindexing process
  4. The indexing process will see the changed entity and update the index tables with the new values.

Upvotes: 1

Related Questions