We are facing huge MYSQL CPU usage. While investigating we found that there are MySQL sleep connections during the CRON run. Is there any way to reduce the CPU usage and the sleep connections. Please check the attached screenshots.
We found the following suggestions:
Magento 2.4 Database Connection Usage
We have a large catalog and large number of tier prices, approx. 2000000. Is this suggestion suitable to fix our problem. Please suggest a better solution if you have any.
Thanks.
| Id | User | Host | db | Command | Time | State |Info | Progress |
+---------+----------------------------+-----------------+
| 2777768 | user_user_live_245 | 127.0.0 | user_user_live | Sleep | 2704 | | NULL | 0.000 |
| 2777774 | user_user_live_245 | 127.0.0.1:3 | user_user_live | Query | 0 | Sending data | UPDATE catalog_product_index_price_temp
AS i
INNER JOIN catalog_product_index_website
AS cpiw
ON cpiw.website_id = i.website_id
INNER JOIN catalogrule_product_price
AS cpp
ON cpp.product_id = i.entity_id AND cpp.customer_group_id = i.customer_group_id AND cpp.website_id = i.website_id AND cpp.rule_date = cpiw.website_date
SET i
.final_price
= LEAST(final_price, IFNULL(cpp.rule_price, i.final_price)), i
.min_price
= LEAST(min_price, IFNULL(cpp.rule_price, i.min_price))
WHERE (i.entity_id IN (13, 14, 18, 383, 387, 395, 399, 410, 414, 416, 418, 419, 423, 424, 429, 431, 433, 436, 437, 447, 448, 449, 450, 451, 452, 453, 454, 459, 461, 463, 472, 473, 474, 475, 481, 482, 486, 487, 488, 489, 490, 491, 492, 494, 509, 510, 511, 513, 516, 518, 558, 559, 560, 561, 565, 566, 568, 582, 584, 585, 587, 588, 589, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630)) | 0.000 |
| 2782841 | user_user_live_245 | localhost | user_user_live | Query | 0 | starting | SHOW FULL PROCESSLIST | 0.000 |
| 2782875 | user_user_live_245 | 127.0.0.1:64063 | user_user_live | Sleep | 0 | | NULL | 0.000 |