Skip to content

Commit 340f5f8

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

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ private function reindexByBatchWithDimensions(
311311
if (!empty($entityIds)) {
312312
$this->dimensionTableMaintainer->createMainTmpTable($dimensions);
313313
$temporaryTable = $this->dimensionTableMaintainer->getMainTmpTable($dimensions);
314-
$this->_emptyTable($temporaryTable);
315314

316315
$priceIndexer->executeByDimensions($dimensions, \SplFixedArray::fromArray($entityIds, false));
317316

@@ -354,7 +353,6 @@ private function reindexBatch(PriceInterface $priceIndexer, Select $batch): void
354353
if (!empty($entityIds)) {
355354
// Temporary table will created if not exists
356355
$idxTableName = $this->_defaultIndexerResource->getIdxTable();
357-
$this->_emptyTable($idxTableName);
358356

359357
if ($priceIndexer->getIsComposite()) {
360358
$this->_copyRelationIndexData($entityIds);
@@ -494,17 +492,4 @@ protected function getIndexTargetTable(): string
494492
{
495493
return $this->activeTableSwitcher->getAdditionalTableName($this->_defaultIndexerResource->getMainTable());
496494
}
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-
}
510495
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,8 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
122122
$query = $select->crossUpdateFromSelect(['i' => $finalPriceTable]);
123123
$connection->query($query);
124124

125-
// phpcs:ignore Magento2.SQL.RawQuery.FoundRawSql
126-
$connection->query('TRUNCATE TABLE ' . $connection->quoteIdentifier($coaTable));
127-
// phpcs:ignore Magento2.SQL.RawQuery.FoundRawSql
128-
$connection->query('TRUNCATE TABLE ' . $connection->quoteIdentifier($copTable));
125+
$connection->dropTemporaryTable($coaTable);
126+
$connection->dropTemporaryTable($copTable);
129127
}
130128

131129
/**

0 commit comments

Comments
 (0)