https://github.com/magento/magento2/pull/35524/files From 1119260c0865c4f2f1db6acfad09607f8e27d885 Mon Sep 17 00:00:00 2001 From: Nick Anstee Date: Mon, 23 May 2022 17:31:41 +0200 Subject: [PATCH] Ensure deleted index data is integer IDs With a very large product set (~213k) on 1 of our sites, the price index (and through the use of MSI, the inventory index) takes a very long time to complete, with multiple hours spent executing deleteIndexData. It seems the primary cause of this slowdown is string to int conversions or vice versa in MySQL, and ensuring that all IDs are integers beforehand yields much more consistent and reasonable performance on these larger sets --- .../Catalog/Model/Indexer/Product/Price/AbstractAction.php | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/magento/module-catalog/Model/Indexer/Product/Price/AbstractAction.php b/vendor/magento/module-catalog/Model/Indexer/Product/Price/AbstractAction.php index 8e4eda70b708..0f794c6c3559 100644 --- a/vendor/magento/module-catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/vendor/magento/module-catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -429,6 +429,7 @@ protected function _reindexRows($changedIds = []) */ private function deleteIndexData(array $entityIds) { + $entityIds = array_unique(array_map('intval', $entityIds)); foreach ($this->dimensionCollectionFactory->create() as $dimensions) { $select = $this->getConnection()->select()->from( ['index_price' => $this->tableMaintainer->getMainTableByDimensions($dimensions)],