Skip to content

Commit 6d73999

Browse files
committed
ACP2E-2204: Price indexing performance gradually degrades overtime
- truncate statement breaks transactions
1 parent 07693fd commit 6d73999

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,7 @@ protected function _insertFromTable($sourceTable, $destTable, $where = null)
367367
*/
368368
protected function _emptyTable($table)
369369
{
370-
$connection = $this->getConnection();
371-
// phpcs:ignore Magento2.SQL.RawQuery.FoundRawSql
372-
$connection->query('TRUNCATE TABLE ' . $connection->quoteIdentifier($table));
370+
$this->getConnection()->delete($table);
373371
}
374372

375373
/**

app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,4 +494,17 @@ protected function getIndexTargetTable(): string
494494
{
495495
return $this->activeTableSwitcher->getAdditionalTableName($this->_defaultIndexerResource->getMainTable());
496496
}
497+
498+
/**
499+
* Removes all data from the table
500+
*
501+
* @param string $table
502+
* @return void
503+
*/
504+
protected function _emptyTable($table): void
505+
{
506+
$connection = $this->_defaultIndexerResource->getConnection();
507+
// phpcs:ignore Magento2.SQL.RawQuery.FoundRawSql
508+
$connection->query('TRUNCATE TABLE ' . $connection->quoteIdentifier($table));
509+
}
497510
}

0 commit comments

Comments
 (0)