Skip to content

Commit eb3aea5

Browse files
committed
ACP2E-2673: Price partial indexing performance
- slow delete query is excluded from execution when its conditions result in 0 affected rows
1 parent bfea788 commit eb3aea5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,18 @@ function ($type) use ($productsTypes) {
437437
*/
438438
private function deleteOutdatedData(array $entityIds, string $temporaryTable, string $mainTable): void
439439
{
440+
$connection = $this->getConnection();
441+
$describe = $connection->describeTable($connection->getTableName($temporaryTable));
442+
if (false === $describe['entity_id']['NULLABLE']) {
443+
return;
444+
}
445+
440446
$joinCondition = [
441447
'tmp_table.entity_id = main_table.entity_id',
442448
'tmp_table.customer_group_id = main_table.customer_group_id',
443449
'tmp_table.website_id = main_table.website_id',
444450
];
445-
$select = $this->getConnection()->select()
451+
$select = $connection->select()
446452
->from(['main_table' => $mainTable], null)
447453
->joinLeft(['tmp_table' => $temporaryTable], implode(' AND ', $joinCondition), null)
448454
->where('tmp_table.entity_id IS NULL')

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function testBatchProcessing()
143143
$select->method('join')->willReturnSelf();
144144
$adapter = $this->createMock(AdapterInterface::class);
145145
$adapter->method('select')->willReturn($select);
146-
$adapter->method('describeTable')->willReturn([]);
146+
$adapter->method('describeTable')->willReturn(['entity_id' => ['NULLABLE' => true]]);
147147
$this->defaultIndexerResource->method('getConnection')->willReturn($adapter);
148148
$adapter->method('fetchAll')->with($select)->willReturn([]);
149149

0 commit comments

Comments
 (0)