Skip to content

Commit 2a774fc

Browse files
authored
Merge pull request #7548 from magento-performance/MCP-964
[Performance] Product Price index issue in PAT Builds
2 parents 21c67ae + 322ebfc commit 2a774fc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
112112
$indexer->setScheduled($indexersState[$indexerId['indexer_id']]);
113113
}
114114

115+
$this->optimizeTables($fixtureModel->getObjectManager(), $output);
116+
115117
/** @var \Magento\Setup\Fixtures\IndexersStatesApplyFixture $indexerFixture */
116118
$indexerFixture = $fixtureModel
117119
->getFixtureByName(\Magento\Setup\Fixtures\IndexersStatesApplyFixture::class);
@@ -168,4 +170,22 @@ private function executeFixture(\Magento\Setup\Fixtures\Fixture $fixture, Output
168170
$resultTime = (int) ($endTime - $startTime);
169171
$output->writeln('<info> done in ' . gmdate('H:i:s', $resultTime) . '</info>');
170172
}
173+
174+
/**
175+
* Optimize tables after entities generation.
176+
*
177+
* @param \Magento\Framework\ObjectManagerInterface $objectManager
178+
* @param OutputInterface $output
179+
* @return void
180+
*/
181+
private function optimizeTables(
182+
\Magento\Framework\ObjectManagerInterface $objectManager,
183+
OutputInterface $output
184+
): void {
185+
$connect = $objectManager->get(ResourceConnection::class)->getConnection();
186+
$output->writeln("<info>Optimize tables</info>");
187+
foreach ($connect->getTables() as $tableName) {
188+
$connect->query("OPTIMIZE TABLE `$tableName`");
189+
}
190+
}
171191
}

0 commit comments

Comments
 (0)