BRAHMA TECHNOLAB

Before going with the woocommerce issue fixing, lets first understand what exactly woocommerce is and why it is so popular.

WooCommerce is an eCommerce plugin that works with WordPress. WooCommerce has many useful features, including order tracking and customer engagement as well as deliveries status update, managing inventory and many more. With more than 27 million downloads so far, WooCommerce powers 99% of all WordPress stores. WooCommerce is a moderate level of difficulty. It’s simple to use for novice website owners.

But sometimes the good things fo have some loopholes and so thus the woocommerce has.

When our client came and informed us that our woo-commerce orders admin screen was very slow. We did research and realized it takes almost 10 minutes to search for any order number OR username.

Slow Woocommerce?

Struggling from having thousands of Woocommerce orders with millions of meta records? We have here mentioned how a crawling slow Woccommerce installation was tuned to be very fast:

Order search is now a magnitude faster: from previously 80 secs to less than one sec., listing 20-40 orders was taking 20+ seconds, opening an order detail screen up to 80 seconds!

After these adjustments, Woocommerce order searches and opening an order detail screen are faster.

HOW MUCH FASTER IS IT NOW?

2500%

Faster to search for an order

4900%

Faster to open an order detail screen

USE CASEBEFOREAFTER% FASTER
ORDER LIST SCREEN24+ secsless than 1 second2300%
ORDER DETAIL32+ secs0.64 seconds4900%
SEARCH BY EMAIL80+ secsless than 1 second7900%
SEARCH BY NAME29+ secsless than 1 second2800%
SEARCH BY ORDER#26+ secsless than 1 second2500%

Follow These 3 Steps to Fix a Slow Woocommerce Installation:

1- FIX MYSQL DATABASE

During the process of WordPress upgrade from 3. x to 4. x to 5. x this WordPress installation gradually started to suffer from a major WooCommerce slowdown when listing orders, searching orders, and opening an order detail screen:

Updated June 2021: WordPress version: 5.7.2, WooCommerce version: 5.4.1, UTf-8, InnoDB tables

1.1 – Use SqlMonitor to find the slow search

1.2 – Run EXPLAIN on the slow query in mySql WorkBench

During the debugging, we noticed that no index was used, even though the meta_key field has an index assigned.

Hence we concluded that why NOT to take advantage of MySQL Indexing to speedup the Query Result

Take advantage of fast indexing and not slow sequential search:

wp_postmeta table is responsible for this and which is described in more detail on WordPress Core

The meta_key field was a VARCHAR(255), and being too long in size, it did exceed its maximum index length of 767 bytes and therefore did not use the index. Let’s check how much space we used from this VARCHAR(255) field.

The result returns ’49’. So the longest value of all the ‘7,014,698’ meta records. We currently use only 49 chars, not even close to the 255 chars the field was assigned to.

HIRE US TO FIX THIS ISSUE FOR YOU

This installation had 62K Woocommerce orders with ‘7,014,698’ related wp_postmeta records. Let’s take the field size down to a VARCHAR(191) to stay within the index limit together: (It is smart to back up your table or DB first.)

Let’s check out the query after adjusting the field size:

Result: 0.025 sec – Very Fast!

No Time? Too busy? Ask a specialist for help ▶

2 – LIMIT FIELDS TO SEARCH IN

One more improvement is to speed up Woocommerce without needing full root access to your server. Limiting the number of fields to search for to the most relevant ones:

/**
* Limit woocommerce order search fields. 
*/
function custom_woocommerce_shop_order_search_fields( $search_fields ) {

    // error_log( 'currently searching in these order fields: ' . print_r($search_fields, true) );
    unset( $search_fields );
    $search_fields[] = '_meta_key_one';
    $search_fields[] = '_meta_key_two';
    $search_fields[] = '_meta_key_three';

    // error_log( 'now only searching in these order fields: ' . print_r($search_fields, true) );
    return $search_fields;

}
add_filter( 'woocommerce_shop_order_search_fields', 'custom_woocommerce_shop_order_search_fields' );

3 – IMPLEMENT ELASTIC SEARCH

Some extra improvements to speed up Woocommerce are implemented to make it more advanced if you have root access to your web hosting account, download and install ElasticSearch Server, the Elastic Press WordPress plugin, and WC-CLI.

Once the ElasticSearch Server has been installed successfully, we can either use the “ElasticPress WooCommerce” plugin to offer all critical WooCommerce SQL queries to Elasticsearch instead of MySQL or write our own.

Winding Up

The optimization of your WooCommerce products pages won’t just engage your customers and increase their satisfaction they will also motivate customers to make a purchase. The mentioned tricks to make your woo-commerce store faster will definitely help you and enhance the efficiency to improve the performance of product pages.

A professional and experienced Web development company India will help you get a WooCommerce setup without any slowing issues and errors. It’s always

Leave a Reply

Your email address will not be published.