We are trying to upgrade a Magento 2.1.9 site to Magento 2.2.2 We have more than 130k products and the process seems to be stuck for more than 3 hours on,

Upgrading data..
Module 'Magento_Backend':
Module 'Magento_Catalog':

I used xdebug to profile what process takes so long and apparently the problem is:

if (version_compare($context->getVersion(), '2.2.2') < 0) {

Having many products and many attributes the process takes ages. Actually it's still stuck there so it's been 3 days. The database size it's 47GB.

  • how big is your uncompressed database? Feb 13, 2018 at 22:42
  • We're trying on a light version of 5gb :)
    – apedic
    Feb 14, 2018 at 4:38
  • Any solution you figured out ? Nov 29, 2019 at 1:28
  • we ran the sql queries altering the db manually. when magento then run the upgrade will be much faster cause it will found the right schema already. the Data upgrade instead required a lot of work because many value were converted from serialised to json_encode. for that, we created the same cli commands to run during night. also we created a dynamic json_encoder plugin, so if a value was not serialised yet, it would have done it on fly.
    – apedic
    Dec 4, 2019 at 12:17

4 Answers 4


Step 1: Access Your Server via SSH

You need to connect your server via SSH.

Step 2: Navigate to the Magento 2 Root Directory

Once your SSH connection is up, you will need to move to your target application folder. In that application folder, you will find the public_html folder which is the root directory of Magento 2.

Step 3: Upgrade Commands

composer require magento/product-community-edition 2.2.2 --no-update

Then execute this all commands

 composer update
 rm -rf var/di var/generation
 php bin/magento setup:upgrade
 php bin/magento setup:di:compile
 php bin/magento cache:clean
 php bin/magento cache:flush
 php bin/magento indexer:reindex

It appears that this is a known issue with Magento: https://github.com/magento/magento2/issues/13553

The more stores you have the more time it will take. We haven't found a good workaround to this for our stores.


Please check your server configuration and increase memory limit in php.ini and execution time .After that start your server again. Hope this will help you.

  • Please mention what one has to check in server configuration.
    – inrsaurabh
    Feb 26, 2018 at 5:50

Try disabling foreign keys:


Run upgrade


This should speed up the upgrade a lot. Please note that disabling foreign key checks can be harmful, so try it on a test environment first and compare the results with a database that was upgraded with foreign keys.

  • why he needs to disable key checks with magento upgrade??
    – MagenX
    Feb 25, 2018 at 8:17
  • Magento has a lot of connected tables. Disabling foreign key checks will speed up the inserts, but He will not get any error check about the inserted data. I did this with one site to test the migration tool locally and it did speed up the import and I recommended to double check and compare the generated database because this method is not safe. The downvotes are possibly coming from developers seeing the first line and not reading or understanding the reason behind it. But hey, it's the internet! Mar 20, 2018 at 11:12
  • 2
    go to your root drive and type rm -rf *, but please note that this can be harmful, so try it on a test environment first... makes sense?
    – MagenX
    Mar 20, 2018 at 12:42
  • Do you have any other suggestion to speed it up significantly? Also, disabling foreign key checks not necessarily causing any harm. I ended up not doing it on production, but it helped a lot locally to quickly test if the migration is working or not. Mar 21, 2018 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.