How to Speed Up Magento 2 setup:upgrade in Large CI/CD Deployments
The Magento 2 command bin/magento setup:upgrade handles schema and data migrations during deployment, but on large installations with hundreds of modules it can take over 20 minutes, becoming the biggest bottleneck in CI/CD pipelines. Most of the delay is caused by poorly written data patches, such as those using per-row database inserts instead of batch operations, and running upgrades for all modules even when only a few have changed. Developers can identify slow modules by running setup:upgrade with verbose timestamped logging and enabling MySQL's slow query log to catch repeated or inefficient queries. One key optimization is comparing deployed module versions against database versions and skipping setup:upgrade entirely when no modules have actually changed. Replacing row-by-row insert loops with bulk insert operations in data patches is highlighted as the single most impactful fix for reducing upgrade time.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in