Skip to content

Commit 9277060

Browse files
author
Stanislav Idolov
committed
MAGETWO-64477: [Indexer optimizations] Indexation process in non-locking way for product indexer
1 parent d148bbc commit 9277060

File tree

2 files changed

+7
-12
lines changed
  • app/code/Magento/Catalog

2 files changed

+7
-12
lines changed

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
*/
1717
class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
1818
{
19-
20-
/**
21-
* Row count to process in a batch
22-
*/
23-
const DEFAULT_BATCH_SIZE = 100000;
24-
2519
/**
2620
* @var \Magento\Framework\Indexer\BatchSizeManagementInterface
2721
*/
@@ -47,7 +41,7 @@ class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
4741
*
4842
* @var int
4943
*/
50-
private $batchSize;
44+
private $batchRowsCount;
5145

5246
/**
5347
* @param ResourceConnection $resource
@@ -58,7 +52,7 @@ class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
5852
* @param \Magento\Framework\Indexer\BatchProviderInterface|null $batchProvider
5953
* @param \Magento\Framework\EntityManager\MetadataPool|null $metadataPool
6054
* @param \Magento\Indexer\Model\Indexer\StateFactory|null $stateFactory
61-
* @param int|null $batchSize
55+
* @param int|null $batchRowsCount
6256
*/
6357
public function __construct(
6458
\Magento\Framework\App\ResourceConnection $resource,
@@ -69,7 +63,7 @@ public function __construct(
6963
\Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null,
7064
\Magento\Framework\EntityManager\MetadataPool $metadataPool = null,
7165
\Magento\Indexer\Model\Indexer\StateFactory $stateFactory = null,
72-
$batchSize = null
66+
$batchRowsCount = null
7367
) {
7468
parent::__construct(
7569
$resource,
@@ -90,7 +84,7 @@ public function __construct(
9084
$this->indexerStateFactory = $stateFactory ?: $objectManager->get(
9185
\Magento\Indexer\Model\Indexer\StateFactory::class
9286
);
93-
$this->batchSize = $batchSize ?: self::DEFAULT_BATCH_SIZE;
87+
$this->batchRowsCount = $batchRowsCount;
9488
}
9589

9690
/**
@@ -215,12 +209,12 @@ private function reindexCategoriesBySelect(\Magento\Framework\DB\Select $basicSe
215209
{
216210
$entityMetadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
217211
$columns = array_keys($this->connection->describeTable($this->getMainTmpTable()));
218-
$this->batchSizeManagement->ensureBatchSize($this->connection, $this->batchSize);
212+
$this->batchSizeManagement->ensureBatchSize($this->connection, $this->batchRowsCount);
219213
$batches = $this->batchProvider->getBatches(
220214
$this->connection,
221215
$entityMetadata->getEntityTable(),
222216
$entityMetadata->getIdentifierField(),
223-
$this->batchSize
217+
$this->batchRowsCount
224218
);
225219
foreach ($batches as $batch) {
226220
$this->clearTmpData();

app/code/Magento/Catalog/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@
950950
</type>
951951
<type name="Magento\Catalog\Model\Indexer\Category\Product\Action\Full">
952952
<arguments>
953+
<argument name="batchRowsCount" xsi:type="number">100000</argument>
953954
<argument name="batchSizeManagement" xsi:type="object">Magento\Catalog\Model\Indexer\CategoryProductBatchSize</argument>
954955
</arguments>
955956
</type>

0 commit comments

Comments
 (0)