Skip to content

Commit

Permalink
[impr-OpenMage#188] Unnecessary table metadata locks when reindexing
Browse files Browse the repository at this point in the history
disable 'ALTER TABLE ... DISABLE KEYS' statements by default,
and remove useless calls to useDisableKeys()
  • Loading branch information
bob2021 authored and edannenberg committed Sep 19, 2018
1 parent 7b0a7db commit 7e4c317
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public function reindexEntities($processIds)
$adapter->delete($this->getMainTable(), $where);

// insert new index
$this->useDisableKeys(false);
$this->insertFromTable($this->getIdxTable(), $this->getMainTable());
$this->useDisableKeys(true);

$adapter->commit();
} catch (Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ protected function _copyIndexDataToMainTable($processIds)
$write->delete($this->getIdxTable(), $where);

// insert new index
$this->useDisableKeys(false);
$this->insertFromTable($this->getIdxTable(), $this->getMainTable());
$this->useDisableKeys(true);

$this->commit();
} catch (Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,9 @@ public function reindexAll()
*/
public function reindexEntity($entityIds)
{
$this->useDisableKeys(false);
$this->_prepareFinalPriceData($entityIds);
$this->_applyCustomOption();
$this->_movePriceDataToIndexTable();
$this->useDisableKeys(true);

return $this;
}
Expand Down
2 changes: 0 additions & 2 deletions app/code/core/Mage/Index/Model/Indexer/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ public function disableKeys()

$resourceModel = $this->getResource();
if ($resourceModel instanceof Mage_Index_Model_Resource_Abstract) {
$resourceModel->useDisableKeys(true);
$resourceModel->disableTableKeys();
}

Expand All @@ -211,7 +210,6 @@ public function enableKeys()

$resourceModel = $this->getResource();
if ($resourceModel instanceof Mage_Index_Model_Resource_Abstract) {
$resourceModel->useDisableKeys(true);
$resourceModel->enableTableKeys();
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Index/Model/Resource/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ abstract class Mage_Index_Model_Resource_Abstract extends Mage_Core_Model_Resour
*
* @var bool
*/
protected $_isDisableKeys = true;
protected $_isDisableKeys = false;

/**
* Whether table changes are allowed
Expand Down

0 comments on commit 7e4c317

Please sign in to comment.