Skip to content

Commit 72b03df

Browse files
committed
MAGETWO-91589: Slow query delete on sub SELECT query
- Fix static tests
1 parent 261f620 commit 72b03df

File tree

1 file changed

+6
-20
lines changed
  • app/code/Magento/CatalogUrlRewrite/Model/ResourceModel/Category

1 file changed

+6
-20
lines changed

app/code/Magento/CatalogUrlRewrite/Model/ResourceModel/Category/Product.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\CatalogUrlRewrite\Model\ResourceModel\Category;
710

811
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
@@ -49,7 +52,7 @@ protected function _construct()
4952
public function saveMultiple(array $insertData)
5053
{
5154
$connection = $this->getConnection();
52-
if (sizeof($insertData) <= self::CHUNK_SIZE) {
55+
if (count($insertData) <= self::CHUNK_SIZE) {
5356
return $connection->insertMultiple($this->getTable(self::TABLE_NAME), $insertData);
5457
}
5558
$data = array_chunk($insertData, self::CHUNK_SIZE);
@@ -86,7 +89,7 @@ public function removeMultiple(array $removeData)
8689
*/
8790
public function removeMultipleByProductCategory(array $filter)
8891
{
89-
return $this->getConnection()->deleteFromSelect($this->prepareJoin($filter), self::TABLE_NAME);
92+
return $this->getConnection()->deleteFromSelect($this->prepareSelect($filter), self::TABLE_NAME);
9093
}
9194

9295
/**
@@ -95,7 +98,7 @@ public function removeMultipleByProductCategory(array $filter)
9598
* @param array $data
9699
* @return \Magento\Framework\DB\Select
97100
*/
98-
private function prepareJoin($data)
101+
private function prepareSelect($data)
99102
{
100103
$select = $this->getConnection()->select();
101104
$select->from(DbStorage::TABLE_NAME);
@@ -108,21 +111,4 @@ private function prepareJoin($data)
108111
}
109112
return $select;
110113
}
111-
112-
/**
113-
* Prepare select statement for specific filter
114-
*
115-
* @param array $data
116-
* @return \Magento\Framework\DB\Select
117-
*/
118-
private function prepareSelect($data)
119-
{
120-
$select = $this->getConnection()->select();
121-
$select->from($this->getTable(DbStorage::TABLE_NAME), 'url_rewrite_id');
122-
123-
foreach ($data as $column => $value) {
124-
$select->where($this->getConnection()->quoteIdentifier($column) . ' IN (?)', $value);
125-
}
126-
return $select;
127-
}
128114
}

0 commit comments

Comments
 (0)