Index the meta_key in the postmeta table

Speed up your website by making sure that the meta_key column in the postmeta table is properly indexed, making queries much faster on larger sites.

While the column appears to be indexed by default, the use of utf8mb4 now limits the indexing of columns to a maximum of 191 characters. The meta_key column being 256 characters, it is not indexed.

This power tweak changes the column size down to 191 characters if possible, and makes sure the column can be indexed.

Speed up WooCommerce’s “Get total spent” query

When a customer places their first order, WooCommerce calculates the total spent by running a very slow query. This Power Tweak replaces this query by two separate and much more efficient queries.

This will be specially effective on an e-commerce website with a large amount 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).