How to speed up WooCommerce’s get_total_spent query
This is one of two ‘Power Tweaks’ which are a feature of WP-Optimize Premium.
When a customer places their first order, WooCommerce calculates the total spent by running a very slow query. This power tweak replaces this slow query with two separate and much more efficient queries.
This will be especially effective on e-commerce websites containing large amounts of customers and orders.
It uses the filter:
woocommerce_customer_get_total_spent
to calculate the total spent when the user meta:
_money_spent
is not set.
This issue has been reported to WooCommerce, but not addressed yet (See issue on Github).