Skip to content

Commit 88f10c5

Browse files
committed
Improve performance of "in" condition on some version of MySQL
Fix static test, SVC failures and apply requested changes
1 parent 12d3ebf commit 88f10c5

File tree

42 files changed

+91
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+91
-86
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function joinPrices($websiteId)
215215
public function setOptionIdsFilter($optionIds)
216216
{
217217
if (!empty($optionIds)) {
218-
$this->getSelect()->where('selection.option_id IN (?)', $optionIds, \Zend_Db::BIGINT_TYPE);
218+
$this->getSelect()->where('selection.option_id IN (?)', $optionIds, \Zend_Db::INT_TYPE);
219219
}
220220
return $this;
221221
}
@@ -229,7 +229,7 @@ public function setOptionIdsFilter($optionIds)
229229
public function setSelectionIdsFilter($selectionIds)
230230
{
231231
if (!empty($selectionIds)) {
232-
$this->getSelect()->where('selection.selection_id IN (?)', $selectionIds, \Zend_Db::BIGINT_TYPE);
232+
$this->getSelect()->where('selection.selection_id IN (?)', $selectionIds, \Zend_Db::INT_TYPE);
233233
}
234234
return $this;
235235
}

app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private function fetch() : array
108108
}
109109

110110
$linkCollection->getSelect()
111-
->where($field . ' IN (?)', $this->parentIds, \Zend_Db::BIGINT_TYPE);
111+
->where($field . ' IN (?)', $this->parentIds, \Zend_Db::INT_TYPE);
112112

113113
/** @var Selection $link */
114114
foreach ($linkCollection as $link) {

app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ private function getLinkIds(array $entityIds)
425425
)->where(
426426
'e.entity_id IN (?)',
427427
$entityIds,
428-
\Zend_Db::BIGINT_TYPE
428+
\Zend_Db::INT_TYPE
429429
);
430430

431431
return $this->connection->fetchCol($select);
@@ -471,11 +471,11 @@ protected function getAttributeTypeValues($type, $entityIds, $storeId)
471471
)->where(
472472
"e.entity_id IN (?)",
473473
$entityIds,
474-
\Zend_Db::BIGINT_TYPE
474+
\Zend_Db::INT_TYPE
475475
)->where(
476476
'def.store_id IN (?)',
477477
[Store::DEFAULT_STORE_ID, $storeId],
478-
\Zend_Db::BIGINT_TYPE
478+
\Zend_Db::INT_TYPE
479479
);
480480

481481
return $this->connection->fetchAll($select);

app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected function filterIdsByStore(array $ids, $store)
120120
)->where(
121121
"entity_id IN (?)",
122122
$ids,
123-
\Zend_Db::BIGINT_TYPE
123+
\Zend_Db::INT_TYPE
124124
);
125125

126126
$resultIds = [];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ protected function createAnchorSelect(Store $store)
508508
$this->connection->quoteInto(
509509
'cc2.parent_id = cc.entity_id AND cc.entity_id NOT IN (?)',
510510
$rootCatIds,
511-
\Zend_Db::BIGINT_TYPE
511+
\Zend_Db::INT_TYPE
512512
),
513513
[]
514514
)->joinInner(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private function reindexCategoriesBySelect(Select $basicSelect, $whereCondition,
282282
$this->connection->delete($this->tableMaintainer->getMainTmpTable((int)$store->getId()));
283283
$entityIds = $this->connection->fetchCol($query);
284284
$resultSelect = clone $basicSelect;
285-
$resultSelect->where($whereCondition, $entityIds, \Zend_Db::BIGINT_TYPE);
285+
$resultSelect->where($whereCondition, $entityIds, \Zend_Db::INT_TYPE);
286286
$this->connection->query(
287287
$this->connection->insertFromSelect(
288288
$resultSelect,

app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private function getProductIdsWithParents(array $childProductIds): array
151151
->select()
152152
->from(['relation' => $this->getTable('catalog_product_relation')], [])
153153
->distinct(true)
154-
->where('child_id IN (?)', $childProductIds, \Zend_Db::BIGINT_TYPE)
154+
->where('child_id IN (?)', $childProductIds, \Zend_Db::INT_TYPE)
155155
->join(
156156
['cpe' => $this->getTable('catalog_product_entity')],
157157
'relation.parent_id = cpe.' . $fieldForParent,
@@ -215,7 +215,7 @@ protected function removeEntries()
215215
protected function getNonAnchorCategoriesSelect(\Magento\Store\Model\Store $store)
216216
{
217217
$select = parent::getNonAnchorCategoriesSelect($store);
218-
return $select->where('ccp.product_id IN (?)', $this->limitationByProducts, \Zend_Db::BIGINT_TYPE);
218+
return $select->where('ccp.product_id IN (?)', $this->limitationByProducts, \Zend_Db::INT_TYPE);
219219
}
220220

221221
/**
@@ -227,7 +227,7 @@ protected function getNonAnchorCategoriesSelect(\Magento\Store\Model\Store $stor
227227
protected function getAnchorCategoriesSelect(\Magento\Store\Model\Store $store)
228228
{
229229
$select = parent::getAnchorCategoriesSelect($store);
230-
return $select->where('ccp.product_id IN (?)', $this->limitationByProducts, \Zend_Db::BIGINT_TYPE);
230+
return $select->where('ccp.product_id IN (?)', $this->limitationByProducts, \Zend_Db::INT_TYPE);
231231
}
232232

233233
/**
@@ -239,7 +239,7 @@ protected function getAnchorCategoriesSelect(\Magento\Store\Model\Store $store)
239239
protected function getAllProducts(\Magento\Store\Model\Store $store)
240240
{
241241
$select = parent::getAllProducts($store);
242-
return $select->where('cp.entity_id IN (?)', $this->limitationByProducts, \Zend_Db::BIGINT_TYPE);
242+
return $select->where('cp.entity_id IN (?)', $this->limitationByProducts, \Zend_Db::INT_TYPE);
243243
}
244244

245245
/**
@@ -265,7 +265,7 @@ private function getCategoryIdsFromIndex(array $productIds): array
265265
$storeCategories = $this->connection->fetchCol(
266266
$this->connection->select()
267267
->from($this->getIndexTable($store->getId()), ['category_id'])
268-
->where('product_id IN (?)', $productIds, \Zend_Db::BIGINT_TYPE)
268+
->where('product_id IN (?)', $productIds, \Zend_Db::INT_TYPE)
269269
->distinct()
270270
);
271271
$categoryIds[] = $storeCategories;

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ protected function _updateTemporaryTableByStoreValues(
354354
);
355355
if (!empty($changedIds)) {
356356
$select->where(
357-
$this->_connection->quoteInto('et.entity_id IN (?)', $changedIds, \Zend_Db::BIGINT_TYPE)
357+
$this->_connection->quoteInto('et.entity_id IN (?)', $changedIds, \Zend_Db::INT_TYPE)
358358
);
359359
}
360360
$sql = $select->crossUpdateFromSelect(['et' => $temporaryFlatTableName]);
@@ -382,7 +382,7 @@ protected function _updateTemporaryTableByStoreValues(
382382
$this->_connection->quoteInto(
383383
'et.entity_id IN (?)',
384384
$changedIds,
385-
\Zend_Db::BIGINT_TYPE
385+
\Zend_Db::INT_TYPE
386386
)
387387
);
388388
}

app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ protected function _fillTemporaryTable(
348348

349349
if (!empty($changedIds)) {
350350
$select->where(
351-
$this->_connection->quoteInto('e.entity_id IN (?)', $changedIds, \Zend_Db::BIGINT_TYPE)
351+
$this->_connection->quoteInto('e.entity_id IN (?)', $changedIds, \Zend_Db::INT_TYPE)
352352
);
353353
}
354354

@@ -358,7 +358,7 @@ protected function _fillTemporaryTable(
358358
if (count($valueColumns) > 1) {
359359
if (!empty($changedIds)) {
360360
$selectValue->where(
361-
$this->_connection->quoteInto('e.entity_id IN (?)', $changedIds, \Zend_Db::BIGINT_TYPE)
361+
$this->_connection->quoteInto('e.entity_id IN (?)', $changedIds, \Zend_Db::INT_TYPE)
362362
);
363363
}
364364
$sql = $selectValue->insertFromSelect($temporaryValueTableName, $valueColumns, true);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ private function deleteIndexData(array $entityIds)
436436
$select = $this->getConnection()->select()->from(
437437
['index_price' => $this->tableMaintainer->getMainTableByDimensions($dimensions)],
438438
null
439-
)->where('index_price.entity_id IN (?)', $entityIds, \Zend_Db::BIGINT_TYPE);
439+
)->where('index_price.entity_id IN (?)', $entityIds, \Zend_Db::INT_TYPE);
440440
$query = $select->deleteFromSelect('index_price');
441441
$this->getConnection()->query($query);
442442
}
@@ -547,7 +547,7 @@ private function getProductsTypes(array $changedIds = [])
547547
['entity_id', 'type_id']
548548
);
549549
if ($changedIds) {
550-
$select->where('entity_id IN (?)', $changedIds, \Zend_Db::BIGINT_TYPE);
550+
$select->where('entity_id IN (?)', $changedIds, \Zend_Db::INT_TYPE);
551551
}
552552
$pairs = $this->getConnection()->fetchPairs($select);
553553

0 commit comments

Comments
 (0)