Sample Header Ad - 728x90

High CPU usage in AWS RDS

0 votes
1 answer
1037 views
When I visit the woocommerce orders page in WordPress, MySQL RDS CPU usage goes to 100% but the website is working perfectly fine. In 'active sessions' section, "wait/io/tables/sql/handler" is showing cpu usage to 99%. I looked at the performance insights of the database and saw this query: SELECT SQL_CALC_FOUND_ROWS hbm_posts.*, low_stock_amount_meta.meta_value AS low_stock_amount, MAX( product_lookup.date_created ) AS last_order_date FROM hbm_posts LEFT JOIN hbm_wc_product_meta_lookup wc_product_meta_lookup ON hbm_posts.ID = wc_product_meta_lookup.product_id LEFT JOIN hbm_postmeta AS low_stock_amount_meta ON hbm_posts.ID = low_stock_amount_meta.post_id AND low_stock_amount_meta.meta_key = '_low_stock_amount' LEFT JOIN hbm_wc_order_product_lookup product_lookup ON hbm_posts.ID = CASE WHEN hbm_posts.post_type = 'product' THEN product_lookup.product_id WHEN hbm_posts.post_type = 'product_variation' THEN product_lookup.variation_id END WHERE 1=1 AND hbm_posts.post_type IN ('product', 'product_variation') AND ((hbm_posts.post_status = 'publish')) AND wc_product_meta_lookup.stock_quantity IS NOT NULL AND wc_product_meta_lookup.stock_status IN('instock','outofstock') AND ( ( low_stock_amount_meta.meta_value > '' AND wc_product_meta_lookup.stock_quantity '' AND wc_product_meta_lookup.stock_quantity <= CAST(low_stock_amount_meta.meta_value AS SIGNED) ) OR ( ( low_stock_amount_meta.meta_value IS NULL OR low_stock_amount_meta.meta_value <= '' ) AND wc_product_meta_lookup.stock_quantity <= 2 ) ) GROUP BY hbm_posts.ID ORDER BY hbm_posts.post_date DESC, hbm_posts.ID DESC LIMIT 0, 1_posts.ID ORDER BY hbm_posts.post_date DESC, hbm_posts.ID DESC LIMIT 0, 1 I have tried tracing back the query in WordPress, but can't find it anywhere. I searched it with 'string locator', saw query logs in 'query monitor', tried disabling all plugins, and also tried "define('SAVEQUERIES', true);" as stated in this post: https://stackoverflow.com/questions/4660692/is-it-possible-to-print-a-log-of-all-database-queries-for-a-page-request-in-word What can I do to trace back this? Mysql version of server and client is 5.7.34
Asked by Anish Sapkota (101 rep)
Jul 19, 2021, 07:21 AM
Last activity: Apr 13, 2025, 11:05 PM