Jump to content
thirty bees forum

Slowness when changing product category and MySQL error


Recommended Posts

Posted

When I edit products, it takes a lot to save the modifications if I change the category. Sometimes I even get this error:

``` Link to database cannot be established: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")

``` This only happens when editing older products, but newer ones update fast.

I'm using TB 1.0.7 migrated from PS 1.6.1.21

Any idea of what can cause this?

Posted

I've enabled debug profiling and I've got all these messages:

Warning on line 265 in file /home/xxx/public_html/classes/PageCache.php [2] Invalid argument supplied for foreach()

Unknown error on line 280 in file /home/xxx/publichtml/modules/googleshopping/lib/phpseclib/Crypt/RSA.php [8192] Methods with the same name as their class will not be constructors in a future version of PHP; CryptRSA has a deprecated constructor

Unknown error on line 82 in file /home/xxx/publichtml/modules/googleshopping/lib/phpseclib/Crypt/Hash.php [8192] Methods with the same name as their class will not be constructors in a future version of PHP; CryptHash has a deprecated constructor

Unknown error on line 176 in file /home/xxx/publichtml/modules/googleshopping/lib/phpseclib/Math/BigInteger.php [8192] Methods with the same name as their class will not be constructors in a future version of PHP; MathBigInteger has a deprecated constructor

Unknown error on line 115 in file /home/xxx/publichtml/modules/shopgate/vendors/shopgatelibrary/vendors/JSON.php [8192] Methods with the same name as their class will not be constructors in a future version of PHP; sgServicesJSON has a deprecated constructor

Unknown error on line 796 in file /home/xxx/publichtml/modules/shopgate/vendors/shopgatelibrary/vendors/JSON.php [8192] Methods with the same name as their class will not be constructors in a future version of PHP; sgServicesJSON_Error has a deprecated constructor

I've deleted Google Shopping and Shopgate modules because they were not installed and I was not using them.

After deleting those modules, I only get the first warnig:

Warning on line 265 in file /home/xxx/public_html/classes/PageCache.php [2] Invalid argument supplied for foreach()

Posted

This warning has nothing to do with the slowness. You have probably enabled debug mode, not profiling. Enable profiling, and then look at the bottom of the page for performance statistics

0_1540468606619_7ad308d2-87c3-4bb7-b414-d221e7ad6506-image.png

That should give you the basic idea what's slow in your system

0_1540468684968_f4f909b4-258d-416d-bff3-f927331ea186-image.png

Posted

@datakick I tried again and now I've got one of the slow products. It only happens if I change all categories. For example, a product in Categories-New-Covers will not experience a slow modification if changed to Categories-New. But, If I unselect all categories and I select a different category (for example, Sold Idems) saving process will be extremely slow. Here a screenshot of profiling while editing one of these products:

0_1540566278493_debugparameters.jpg

Posted

@cprats we are getting closer. There are over 9000 sql queries -- that's way too many. Normally you shouldn't see more than 300. I bet there's some very inefficient loop that's executing some query over and over.

Please look at the bottom part of the profile stats, and search for section with sql statements named Doubles. It looks something like this (the red number says how many time was this sql executed)

0_1540572494933_07d8dbbb-7985-4a8f-962e-810239291a27-image.png

Posted

It seems the problem is with idproduct. I am using this route to products in schemaurls: {categories:/}{rewrite} instead of the configuration I had when the core was Prestashop: {category:/}{id}-{rewrite}{-:ean13}.html

Posted

There is indeed very inefficient piece of code in classes/Product.php, function cleanPositions. When you remove product from a category, all products that are associated with that category and have higher position gets updated. In your case this leads to thousands of sql updates. They are very fast, but it adds up.

That's also the reason why you experience this problem only with olded products -- they have lower positions inside categories. New products have higher position, so the total number of updates is much lower.

I'll prepare a fix and push it to thirtybees 1.0.8. Meanwhile, this is what you can do to avoid this problem:

edit file classes/Product.php, find function cleanPositions, and remove these lines.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...