4

Magento's index_process* tables (index_process_event and index_event) are getting quite big.

I was looking in Mage_Index (Magento 1.7.0.2) module if there is something in place for cleanup (deleted entries that are not required).

Am I missing something or the information in these tables never get cleaned?

UPDATE: Looking at Mage_Index_Model_Resource_Event::_afterSave() there is a part that is used for deleting records with the status done:

protected function _afterSave(Mage_Core_Model_Abstract $object)
    {
        $processIds = $object->getProcessIds();


        if (is_array($processIds)) {
            $processTable = $this->getTable('index/process_event');
            if (empty($processIds)) {
                $this->_getWriteAdapter()->delete($processTable);
            } else {
                foreach ($processIds as $processId => $processStatus) {

                    if (is_null($processStatus) || $processStatus == Mage_Index_Model_Process::EVENT_STATUS_DONE) {
                        $this->_getWriteAdapter()->delete($processTable, array(
                            'process_id = ?' => $processId,
                            'event_id = ?'   => $object->getId(),
                        ));

                        continue;
                    }
                    $data = array(
                        'process_id' => $processId,
                        'event_id'   => $object->getId(),
                        'status'     => $processStatus
                    );

                    $this->_getWriteAdapter()->insertOnDuplicate($processTable, $data, array('status'));
                }
            }
        }

$processIds is array('new') when a product is saved (and indexes set to manual update) and when the reindex runs this part doesn't seem to run.

1 Answer 1

2

A full reindex should clean them up.

Badly there is no way to trigger the partial reindex from the admin area. But you have access to this via php. Iam not sure anymore what the exact code is, could be something like.

$pCollection = Mage::getSingleton('index/indexer')->getProcessesCollection();
foreach ($pCollection as $process) {
        /** @var $process Mage_Index_Model_Process */
        $process->indexEvents();
        //$process->reindexEverything();
    }

this should iterate over all process_events entries and execute them. problem could get your url_index, there could happen a lot of changes from a single category save, so a full reindex is sometimes faster.

2
  • OK, only a full reindex will clean them up. Which explains the situation I was seeing at the time, the client was using a Async reindex module (which was doing only partial reindexing). Commented Dec 24, 2013 at 9:34
  • For a normal magento store, yes, because you would need to trigger the indexEvents() method yourself via code. But, I remember an async reindex module (I think it was "Fast Asynchronous Re-indexing") which did this just fine. If you have this, you maybe have not configured it correctly? Like adding the cronjob to execute their shell script? You need to know, if its a lot of entries, it does not process all of them at once, it only processes a part of it on every call.
    – Flyingmana
    Commented Dec 24, 2013 at 10:56

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.