Germanized creates loong running query, crashes website every day
-
I’m about to get crazy over this. Not sure when exactly it started, but since about 4 weeks, every single morning, a long running SQL query crashes our site. I’ve even installed a monitor to see that: https://monitor.heukelbach.org/
The website goes down at around 6am every day for about 40 minutes, then recovers, goes down again for about 10 minutes and then it’s fine for the rest of the day.
It’s so heavy that I even cannot login into anything, including PHPMyAdmin. WordPress says “Error establishing database connection”.
Now comes the interesting part: I got the chance to catch the query a few times. It always looks like this, and it’s clearly something about WooCommerce:
SELECT O8WHc_2_posts.* FROM O8WHc_2_posts LEFT JOIN O8WHc_2_postmeta AS mt1 ON ( O8WHc_2_posts.post_parent = mt1.post_id AND mt1.meta_key = '_shipping_country' ) OR ( O8WHc_2_posts.ID = mt1.post_id AND mt1.meta_key = '_shipping_country' ) LEFT JOIN O8WHc_2_postmeta AS mt2 ON ( O8WHc_2_posts.post_parent = mt2.post_id AND mt2.meta_key = '_billing_country' ) OR ( O8WHc_2_posts.ID = mt2.post_id AND mt2.meta_key = '_billing_country' ) LEFT JOIN O8WHc_2_postmeta AS mt3 ON ( O8WHc_2_posts.ID = mt3.post_id AND mt3.meta_key = '_date_paid' ) WHERE 1=1 AND ( NOT mt3.post_id IS NULL AND ( mt3.meta_key = '_date_paid' AND mt3.meta_value >= '1628121600' AND mt3.meta_value <= '1628121600' ) OR O8WHc_2_posts.post_parent > 0 AND ( O8WHc_2_posts.post_date >= '2021-08-05' AND O8WHc_2_posts.post_date <= '2021-08-05' ) ) AND ( ( mt1.post_id IS NULL AND ( mt2.meta_key = '_billing_country' AND mt2.meta_value IN ('AT','BE','BG','CY','CZ','DK','EE','ES','FI','FR','GR','HR','HU','IE','IT','LT','LU','LV','MT','NL','PL','PT','RO','SE','SI','SK','MC','GB') ) ) OR ( mt1.meta_key = '_shipping_country' AND mt1.meta_value IN ('AT','BE','BG','CY','CZ','DK','EE','ES','FI','FR','GR','HR','HU','IE','IT','LT','LU','LV','MT','NL','PL','PT','RO','SE','SI','SK','MC','GB') ) ) AND (O8WHc_2_posts.post_type IN ('shop_order')) AND (O8WHc_2_posts.post_status IN ('wc-processing','wc-on-hold','wc-completed')) GROUP BY O8WHc_2_posts.ID ORDER BY O8WHc_2_posts.post_date ASC LIMIT 0, 2
Now I found the origin of this query in
/woocommerce-germanized/packages/one-stop-shop-woocommerce/src/Queue.php
Line 141:
public static function build_query( $args ) { global $wpdb; $joins = array( "LEFT JOIN {$wpdb->postmeta} AS mt1 ON ( {$wpdb->posts}.post_parent = mt1.post_id AND mt1.meta_key = '_shipping_country' ) OR ( {$wpdb->posts}.ID = mt1.post_id AND mt1.meta_key = '_shipping_country' )", "LEFT JOIN {$wpdb->postmeta} AS mt2 ON ( {$wpdb->posts}.post_parent = mt2.post_id AND mt2.meta_key = '_billing_country' ) OR ( {$wpdb->posts}.ID = mt2.post_id AND mt2.meta_key = '_billing_country' )" );
Can you please help solving this problem?
- The topic ‘Germanized creates loong running query, crashes website every day’ is closed to new replies.