WooCommerce with Thousands of Products: Workarounds for Slow Admin Panel

It’s the WordPress plugin for webshops, without a question. For a shop that is not running WooCommerce with thousands of products, it has a very nice performance, too. However there are limitations and drawbacks running WooCommerce with many products. That’s mostly because it is build upon the WordPress database scheme, which forces WooCommerce to save much data in the wp_postmeta table.

For a shop that is not running WooCommerce with thousands of products, it has a very nice performance, too.

In my current installation, WooCommerce creates 26 meta-fields for each product, so the product related meta-table rows would grow beyond a million for more than 38 461 products. Adding other theme and plugin related fields, you might cross that mark much earlier. Dependent on your server architecture, such a big meta-table, can make some database queries really slow.

… product related meta-table rows would grow beyond a million for more than 38 461 products.

Running such a big shop should make you think about your server architecture. The odds are high that you can’t avoid an upgrade in the long run. However, sometimes a quick workaround is the only way to make things running again. Following two quick and dirty fixes to make your admin panel faster, when running WooCommerce with thousands of products.

WooCommerce Status Dashboard

With WooCommerce activated, you see a admin dashboard widget, that sums up you WooCommerce status, with sales per month, most sold product, order status and stock status. As it turns out, are the stock status queries very slow, dependent on the meta-table size. Here is how to turn of them in your functions.php file:

function themeslug_deactivate_stock_reports($from) {
 global $wpdb;
 return "FROM {$wpdb->posts} as posts WHERE 1=0";
}
add_filter( 'woocommerce_report_low_in_stock_query_from', 'themeslug_deactivate_stock_reports' );
add_filter( 'woocommerce_report_out_of_stock_query_from', 'themeslug_deactivate_stock_reports' ); 

Note, that turning of these reports will result in 0-values in your dashboard!

woocommerce-status-dashboard-query

 

Slow Edit WooCommerce Product for WordPress >= 4.4.0

Another effect of a big meta-table is the product edit page in wp-admin (it affects even the edit page of posts and pages). Since WordPress 4.4.0 there is made an extra query to the meta-table, which might couse long loading times. And of course there is a hook too disable it. Place the following code in your functions.php file.


function themeslug_postmeta_form_keys() {
 return false;
}
add_filter('postmeta_form_keys', 'themeslug_postmeta_form_keys');

Be aware that even this fix not only makes the edit page faster, it turns even off functionality in the meta-field box!

Other measures

There is much more you can do, to make WooCommerce with thousands of products faster, like optimizing your server architecture or using tools like Elastic Search or Redis Cache. If you need to use the above workarounds, you always should consider some of these measures in the long run!

11 thoughts on “WooCommerce with Thousands of Products: Workarounds for Slow Admin Panel

  1. Hey, great post.

    Unfortunately, woocommerce throws up a syntax error when I add the following to functions.php.

    function themeslug_deactivate_stock_reports($from) {
    global $wpdb;
    return “FROM {$wpdb->posts} as posts WHERE 1=0”;
    }
    add_filter( ‘woocommerce_report_low_in_stock_query_from’, ‘themeslug_deactivate_stock_reports’ );
    add_filter( ‘woocommerce_report_out_of_stock_query_from’, ‘themeslug_deactivate_stock_reports’ );

    Any ideas how do I fix this?

    Thanks

    1. Hi, sorry for late reply. If you still looking for a solution, I think that is a problem with WordPress entity-encoding the code you copy from my post.

      FROM {$wpdb->posts} as posts WHERE 1=0

      should be

      FROM {$wpdb->posts} as posts WHERE 1=0

  2. We don’t get any error, but with latest woocommerce and wordpress the dashboard product count does not show zeros…

    Does this function still work? Any additional info? Our shop is very slow with 24000 products.

    1. There has been a WooCommerce update focused on performance issues since I wrote this post… might affect this function. I will try to take a look, when I’ve got some time over.

  3. Hello, nice article. If you go to “Screen Options” and do not choose any widget to show on WooCommerce Status Dashboard, would that have the same effect that your first code has?
    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *