I am new to customizing WordPress and plugins core functions so I have a questions.
Query monitor says I have a duplicate query that is executed like 13-14 times. The query in question is:
SELECT umeta_id as meta_id, meta_key, meta_value
FROM Am1_usermeta
WHERE user_id = 2
ORDER BY umeta_id
It comes from WooCommerce and the callers are:
WC_Data_Store_WP->read_meta()
wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php:94
WC_Data_Store->__call()
wp-content/plugins/woocommerce/includes/class-wc-data-store.php:224
WC_Data->read_meta_data()
wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php:633
WC_Customer_Data_Store->read()
wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php:179
WC_Data_Store->read()
wp-content/plugins/woocommerce/includes/class-wc-data-store.php:159
WC_Customer->__construct()
wp-content/plugins/woocommerce/includes/class-wc-customer.php:113
WooCommerce->initialize_cart()
wp-content/plugins/woocommerce/includes/class-woocommerce.php:847
wc_load_cart()
wp-content/plugins/woocommerce/includes/wc-core-functions.php:2574
WooCommerce->init()
wp-content/plugins/woocommerce/includes/class-woocommerce.php:666
do_action('init')
wp-includes/plugin.php:517
I have Redis cache enabled and I guess this should not happen but still.
My question is is it possible to store this query in cache or transient or cache it using my themes functions php?
Also is it possible, and how, to completely rewrite a query?
I've made a few searches but couldn't find detailed description if and how this is possible.
My goal is to make some optimization to reduce the page load times.