WooCommerce Auto Apply Coupon Extensive Query resulting in performance issues
-
On a large Database, when the number of visitors increases on the website, the auto apply coupon triggers a query that runs every time user adds a product to the cart, this multiple parallel execution of query is degrading the performance of the website.
SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (?,?,?) ORDER BY meta_id ASC
called at
in mysqli_query called at /nas/content/live/wordpress/wp-includes/class-wpdb.php (2349)
in wpdb::_do_query called at /nas/content/live/wordpress/wp-includes/class-wpdb.php (2263)
in wpdb::query called at /nas/content/live/wordpress/wp-includes/class-wpdb.php (3146)
in wpdb::get_results called at /nas/content/live/wordpress/wp-includes/meta.php (1177)
in update_meta_cache called at /nas/content/live/wordpress/wp-includes/post.php (7411)
in update_postmeta_cache called at /nas/content/live/wordpress/wp-includes/post.php (7798)
in _prime_post_caches called at /nas/content/live/wordpress/wp-includes/class-wp-query.php (3334)
in WP_Query::get_posts called at /nas/content/live/wordpress/wp-includes/class-wp-query.php (3824)
in WP_Query::query called at /nas/content/live/wordpress/wp-includes/class-wp-query.php (3956)
in WP_Query::__construct called at /nas/content/live/wordpress/wp-content/plugins/woocommerce-auto-added-coupons/includes/plugins/WJECF_Autocoupon.php (1052)
in WJECF_Autocoupon::get_all_auto_coupons called at /nas/content/live/wordpress/wp-content/plugins/woocommerce-auto-added-coupons/includes/plugins/WJECF_Autocoupon.php (831)
in WJECF_Autocoupon::get_valid_auto_coupons called at /nas/content/live/wordpress/wp-content/plugins/woocommerce-auto-added-coupons/includes/plugins/WJECF_Autocoupon.php (869)
in WJECF_Autocoupon::get_valid_auto_coupon_codes called at /nas/content/live/wordpress/wp-content/plugins/woocommerce-auto-added-coupons/includes/plugins/WJECF_Autocoupon.php (784)
in WJECF_Autocoupon::remove_unmatched_autocoupons called at /nas/content/live/wordpress/wp-content/plugins/woocommerce-auto-added-coupons/includes/plugins/WJECF_Autocoupon.php (683)
in WJECF_Autocoupon::action_woocommerce_check_cart_items called at /nas/content/live/wordpress/wp-includes/class-wp-hook.php (322)
in WP_Hook::apply_filters called at /nas/content/live/wordpress/wp-includes/class-wp-hook.php (348)
in WP_Hook::do_action called at /nas/content/live/wordpress/wp-includes/plugin.php (517)
in do_action called at /nas/content/live/wordpress/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-cart.php (93)
in WC_Shortcode_Cart::output called at /nas/content/live/wordpress/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php (72)
in WC_Shortcodes::shortcode_wrapper called at /nas/content/live/wordpress/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php (85)- The table was retrieved with this index: post_id
- MySQL had to do an extra pass to retrieve the rows in sorted order, which is a cause of poor performance but sometimes unavoidable.
Is there a way to optimize the query or if the support can provide a way via action and/or filter so that third-parties can avoid the expensive query and do their own computation if they want.
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- You must be logged in to reply to this topic.