• hurry

    (@extremist87)


    ive noticed that every time a user visits a product page, the query refreshes can take 25 seconds to finish, if there is a lot of traffic on the website, you can see some queries taking over 100 seconds to complete, see sql query below, it should run this query a few times a day and not every time page has been opened.

    SELECT C.ID AS product_id, A.order_id, A.order_item_id, D.post_status AS order_status, F.meta_value AS customer_id, J.meta_value AS stock_status FROM wp_woocommerce_order_items AS A INNER JOIN wp_woocommerce_order_itemmeta AS B ON A.order_item_id = B.order_item_id AND B.meta_key = ‘_product_id’ INNER JOIN wp_posts AS C ON C.ID = B.meta_value AND C.post_status = ‘publish’ INNER JOIN wp_posts AS D ON A.order_id = D.ID AND D.post_type = ‘shop_order’ LEFT JOIN wp_postmeta AS F ON F.post_id = D.ID AND F.meta_key = ‘_customer_user’ INNER JOIN wp_postmeta AS J ON J.post_id = C.ID AND J.meta_key = ‘_stock_status’ WHERE A.order_item_type = ‘line_item’ AND D.post_status = ‘wc-completed’ AND D.post_parent = 0 AND J.meta_value != ‘outofstock’ AND C.ID NOT IN (24549,41743,144580) ORDER BY A.order_item_id DESC LIMIT 3

  • The topic ‘sql queries causing mysql to crash’ is closed to new replies.