- New SQL enhancement for Scalability Pro to fix WooCommerce long-running query in the product-hero block - August 31, 2023
- Create a static favicon.ico to avoid surplus PHP requests for rush traffic - July 25, 2023
- Breaking Through WooCommerce Restrictions with Super Speedy Filters: The Power of Pretty Permalinks - May 10, 2023
A potential client arrived yesterday on my Discord channel asking for help with slow WooCommerce Variations. It turns out, in their case, they only have a total of 72 variations and yet their product detail page was running incredibly slowly.
As luck would have it for them, I was keen to get back into recording videos for performance analysis and optimisation so I offered them a free quick look after checking the regular things with them.
Table of Contents
Official Woo Stripe plugin causes 1000s of queries
Interestingly, with Query Monitor enabled, they had 3200 queries on the product detail page, and almost 300MB RAM being consumed.
Speeding up WooCommerce variations can be tricky at times. The first thing to check is if you can reduce how many variations you have. In this case, they have one variation which is really a bulk discount so I recommended they remove that but their client really doesn’t want to. It would have reduced their variation count from 72 to 24 but in any case, you can have up to 1000 variations without running too slowly on the product detail page.
The next thing I checked with them was if their object cache was enabled. They got in touch with Siteground who claim to have memcached enabled but if this were true, surely the query count would be reducing on subsequent page loads. (not definitely as it turns out, some bad code from Woo Gateway for Stripe)
In the end, I offered to log in and take a look. You can see the progress in the video below, but the summary is that I drilled down into the queries and found 1000s of repeated queries – queries which at first were claiming to be from WooCommerce, but once I expanded the stack trace in Query Monitor for each of these I discovered that the plugin responsible was the WooCommerce Stripe Payment Gateway plugin.
Yes! That IS the original and official Stripe plugin made by WooCommerce, and it is very badly coded. https://en-gb.wordpress.org/plugins/woocommerce-gateway-stripe/
WooCommerce Stripe Payment Gateway misuses the get_variations function
In my video you will see I discover code which is repeatedly checking if the plugin should display a purchase button or not. It checks, over and over, for terms against product_visibility on the same parent product over and over. They call get_variations over and over. The get_variations function call is frequently a red-flag signal that a plugin is about to do something stupid and expensive that it should not be doing and this case was no different.
I thought that might be the end of it. Often when people turn up and I help them like this they disappear happy, but this person came back with an update for me that I could pass onto my readers.
He had investigated alternative plugins, but he also investigated the features of the official Woo Stripe Gateway plugin and found that the option containing this bad code was the “Enable express checkouts” option. They weren’t using that, so disabling it didn’t even remove any functionality for them but it certainly sped up their variations on their single product page.
We have a lot of optimisations contained within our Scalability Pro plugin to help fix various features but the next big upgrade is going to pave the way for us to provide recommendations like this. I want it to be possible for optimisations we discover to be added to a database so that as users are browsing their website, we can recommend features inside plugins to adjust in order to improve their performance.
Remove Express Checkout option to speed up Woo variations
In this case, the recommendation would be to change this plugin or remove the Express Checkout option.
If you’d like to watch the full video where I take the time to figure out where this problem is coming from you can find it on our reactivated YouTube channel. I will be releasing tips and screencasts like this as often as possible now I have my new graphics card and can actually record stuff without wishing to throw my computer out of the window.
If you do watch the video, excuse my Scottish accent. I cannae help it, but if you do want more content like this be sure to like us on Facebook or follow the YouTube channel or follow me on Twitter. We also have a newsletter signup option somewhere if any of you still use email.