Skip to content

Commit d27734d

Browse files
committed
ACP2E-2204: Price indexing performance gradually degrades overtime
- bypassing table check for truncate
1 parent 45ddfbd commit d27734d

File tree

4 files changed

+5
-28
lines changed

4 files changed

+5
-28
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ protected function _insertFromTable($sourceTable, $destTable, $where = null)
367367
*/
368368
protected function _emptyTable($table)
369369
{
370-
$this->getConnection()->truncateTable($table);
370+
$connection = $this->getConnection();
371+
$connection->query('TRUNCATE TABLE ' . $connection->quoteIdentifier($table));
371372
}
372373

373374
/**

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

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

125-
$connection->truncateTable($coaTable);
126-
$connection->truncateTable($copTable);
125+
$connection->query('TRUNCATE TABLE ' . $connection->quoteIdentifier($coaTable));
126+
$connection->query('TRUNCATE TABLE ' . $connection->quoteIdentifier($copTable));
127127
}
128128

129129
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testModifyPrice(): void
9292
$connection->expects($this->exactly(2))->method('delete');
9393
$connection->expects($this->any())->method('select')->willReturn($select);
9494
$connection->expects($this->any())->method('fetchRow')->willReturn(['exists']);
95-
$connection->expects($this->exactly(2))->method('truncateTable');
95+
$connection->expects($this->exactly(6))->method('query');
9696
$this->resource->expects($this->any())->method('getConnection')->willReturn($connection);
9797
$this->resource->expects($this->any())->method('getTableName')->willReturn('table');
9898
$this->tableStrategy->expects($this->any())

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,10 +2708,6 @@ public function isTableExists($tableName, $schemaName = null)
27082708
$fromDbName = $this->quote($schemaName);
27092709
}
27102710

2711-
if ($this->isTemporaryTable($tableName, $fromDbName)) {
2712-
return true;
2713-
}
2714-
27152711
$sql = sprintf(
27162712
'SELECT COUNT(1) AS tbl_exists FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = %s AND TABLE_SCHEMA = %s',
27172713
$this->quote($tableName),
@@ -2726,26 +2722,6 @@ public function isTableExists($tableName, $schemaName = null)
27262722
return false;
27272723
}
27282724

2729-
/**
2730-
* Checks if temporary table exists with given name
2731-
*
2732-
* @param string $tableName
2733-
* @param string $schemaName
2734-
* @return bool
2735-
* @throws LocalizedException|Zend_Db_Adapter_Exception
2736-
*/
2737-
private function isTemporaryTable(string $tableName, string $schemaName): bool
2738-
{
2739-
$query = "CALL sys.table_exists(" . $schemaName . ", '" . $tableName . "', @exists)";
2740-
$this->query($query);
2741-
2742-
if ($this->rawFetchRow('SELECT @exists')) {
2743-
return true;
2744-
}
2745-
2746-
return false;
2747-
}
2748-
27492725
/**
27502726
* Rename table
27512727
*

0 commit comments

Comments
 (0)