{"data":{"id":"magento2-38050","source":"github-pr","sourceRef":"magento/magento2#38050","title":"Randomly getting flooded with queries from related / upsell / crosssell blocks and price indexing ","pr":{"number":38050,"url":"https://github.com/magento/magento2/pull/38050","author":"ioweb-gr","mergedAt":"2024-05-16T19:44:52Z","mergeCommit":"dcf455e9be4b59b750c38221077067ce71907f2f","headCommit":"ad5548ae382f8a01cac5dec9d1e5fbc3407285c0","baseRef":"2.4-develop","diffSha256":"8345bf6f7ee5b59c9e2d77840b549135aa61fed4f32a22ac2ede4f6a861e9196"},"issues":[{"number":36667,"url":"https://github.com/magento/magento2/issues/36667","title":"Randomly getting flooded with queries from related / upsell / crosssell blocks and price indexing ","labels":["Area: Framework","Area: Performance","Issue: Confirmed","Priority: P2","Progress: done","Reported on 2.4.1","Reproduced on 2.4.x","Triage: Dev.Experience"],"kind":"human"}],"fixedIn":"2.4.8","containingTags":["2.4.8","2.4.8-p1","2.4.8-p2","2.4.8-p3","2.4.8-p4","2.4.8-p5","2.4.9"],"reportedOn":"2.4.1","codeMatch":{"2.4.6":"clean","2.4.6-p1":"clean","2.4.6-p2":"clean","2.4.6-p3":"clean","2.4.6-p4":"clean","2.4.6-p5":"clean","2.4.6-p6":"clean","2.4.6-p7":"clean","2.4.6-p8":"clean","2.4.6-p9":"clean","2.4.6-p10":"clean","2.4.6-p11":"clean","2.4.6-p12":"clean","2.4.6-p13":"clean","2.4.6-p14":"clean","2.4.6-p15":"clean","2.4.7":"clean","2.4.7-p1":"clean","2.4.7-p2":"clean","2.4.7-p3":"clean","2.4.7-p4":"clean","2.4.7-p5":"clean","2.4.7-p6":"clean","2.4.7-p7":"clean","2.4.7-p8":"clean","2.4.7-p9":"clean","2.4.7-p10":"clean","2.4.8":"conflict","2.4.8-p1":"conflict","2.4.8-p2":"conflict","2.4.8-p3":"conflict","2.4.8-p4":"conflict","2.4.8-p5":"conflict","2.4.9":"conflict"},"affectedVersions":["2.4.6","2.4.6-p1","2.4.6-p2","2.4.6-p3","2.4.6-p4","2.4.6-p5","2.4.6-p6","2.4.6-p7","2.4.6-p8","2.4.6-p9","2.4.6-p10","2.4.6-p11","2.4.6-p12","2.4.6-p13","2.4.6-p14","2.4.6-p15","2.4.7","2.4.7-p1","2.4.7-p2","2.4.7-p3","2.4.7-p4","2.4.7-p5","2.4.7-p6","2.4.7-p7","2.4.7-p8","2.4.7-p9","2.4.7-p10"],"components":["magento/module-catalog-inventory"],"files":[{"path":"app/code/Magento/CatalogInventory/Model/Plugin/ProductLinks.php","change":"modified","package":"magento/module-catalog-inventory"}],"stripped":{"tests":["app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php"],"docs":[],"outsideCode":[]},"linesChanged":21,"mergeBatched":false,"excluded":null,"sections":{"description":"The website is down with a lot of queries in queue. Over 2k siilar to this","stepsToReproduce":"I don't have the exact steps, other than the fact that reindexing the price rules takes too long. However in my case I see hundreds of queries like this \n\n![image](https://user-images.githubusercontent.com/20220341/209348797-92c01c79-f24f-48cf-bfab-778ff9d7a8b2.png)\n\nWhich take too long to finish and drop our website","expectedResult":"The site is still working and queries are much faster and won't bring the site down.","actualResult":"The website is down with a lot of queries in queue. Over 2k siilar to this \n\n```\nSELECT `e`.*, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, `cat_index`.`position` AS `cat_index_position`, `stock_status_index`.`is_salable`, `links`.`link_id`, `links`.`product_id` AS `_linked_to_product_id`, `link_attribute_position_int`.`value` AS `position` FROM `catalog_product_entity` AS `e` INNER JOIN `inventory_stock_5` AS `inventory_in_stock` ON e.sku = inventory_in_stock.sku INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '2' INNER JOIN `catalog_category_product_index_store5` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=5 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 INNER JOIN `catalog_product_entity` AS `product` ON product.entity_id = e.entity_id INNER JOIN `inventory_stock_5` AS `stock_status_index` ON product.sku = stock_status_index.sku INNER JOIN `catalog_product_link` AS `links` ON links.linked_product_id = e.entity_id AND links.link_type_id = 4 LEFT JOIN `catalog_product_link_attribute_int` AS `link_attribute_position_int` ON link_attribute_position_int.link_id = links.link_id AND link_attribute_position_int.product_link_attribute_id = '3' INNER JOIN `catalog_product_entity` AS `product_entity_table` ON links.product_id = product_entity_table.entity_id WHERE (inventory_in_stock.is_salable = 1) AND (stock_status_index.is_salable = 1) AND (links.product_id in ('80468')) AND (`e`.`entity_id` != '80468') ORDER BY `position` ASC\n```","source":"issue"},"signatures":[],"labels":{"area":["Framework","Performance"],"component":[],"priority":"P2","severity":null,"reportedOn":["2.4.1"]},"categories":["Performance"],"triage":{"model":"@cf/cloudflare/clef","requestHash":"b9ab00313b5d6088b1c902393d82f66129fd91ba4a7f79ac4952844f24067b97","isBugfix":0.8655,"changeKind":{"choice":"bugfix","probabilities":{"bugfix":0.8975,"feature":0.0088,"refactor":0.0766,"tests_only":0.0081,"docs_only":0.0036,"dependency":0.0054},"confidence":0.7739},"scope":{"score":0.6372,"probabilities":{"0":0.428,"1":0.5067,"2":0.0653},"confidence":0.1663},"risk":{"score":0.8154,"probabilities":{"0":0.4915,"1":0.2016,"2":0.3069},"confidence":0.0646},"area":{"choice":"catalog","probabilities":{"catalog":0.8245,"checkout":0.0117,"customer":0.0057,"admin":0.0177,"graphql_api":0.0054,"framework":0.0859,"frontend":0.0241,"other":0.025},"confidence":0.6444},"securityRelevant":0.0047,"reportedVersion":{"choice":"2.4.1","probabilities":{"2.4.0":0.0037,"2.4.0-p1":0.003,"2.4.1":0.6803,"2.4.1-p1":0.0233,"2.4.2":0.0053,"2.4.2-p1":0.0052,"2.4.2-p2":0.0073,"2.4.3":0.0041,"2.4.3-p1":0.006,"2.4.3-p2":0.0086,"2.4.3-p3":0.0042,"2.4.4":0.0049,"2.4.4-p1":0.0051,"2.4.4-p10":0.0034,"2.4.4-p11":0.0045,"2.4.4-p12":0.0038,"2.4.4-p13":0.0033,"2.4.4-p14":0.0038,"2.4.4-p15":0.0032,"2.4.4-p16":0.0031,"2.4.4-p17":0.0028,"2.4.4-p18":0.0031,"2.4.4-p2":0.0029,"2.4.4-p3":0.0024,"2.4.4-p4":0.0029,"2.4.4-p5":0.0031,"2.4.4-p6":0.003,"2.4.4-p7":0.0028,"2.4.4-p8":0.003,"2.4.4-p9":0.0025,"2.4.5":0.0024,"2.4.5-p1":0.0031,"2.4.5-p10":0.0025,"2.4.5-p11":0.0035,"2.4.5-p12":0.0035,"2.4.5-p13":0.0038,"2.4.5-p14":0.0031,"2.4.5-p15":0.003,"2.4.5-p16":0.0028,"2.4.5-p17":0.0029,"2.4.5-p2":0.0024,"2.4.5-p3":0.0025,"2.4.5-p4":0.0029,"2.4.5-p5":0.0029,"2.4.5-p6":0.0028,"2.4.5-p7":0.0027,"2.4.5-p8":0.0025,"2.4.5-p9":0.0021,"2.4.6":0.0044,"2.4.6-p1":0.0045,"2.4.6-p10":0.0038,"2.4.6-p11":0.0036,"2.4.6-p12":0.0037,"2.4.6-p13":0.0036,"2.4.6-p14":0.004,"2.4.6-p15":0.0038,"2.4.6-p2":0.0027,"2.4.6-p3":0.0029,"2.4.6-p4":0.0041,"2.4.6-p5":0.003,"2.4.6-p6":0.0029,"2.4.6-p7":0.0028,"2.4.6-p8":0.0026,"2.4.6-p9":0.0023,"2.4.7":0.0027,"2.4.7-p1":0.0036,"2.4.7-p10":0.0041,"2.4.7-p2":0.0035,"2.4.7-p3":0.0042,"2.4.7-p4":0.0061,"2.4.7-p5":0.0039,"2.4.7-p6":0.0068,"2.4.7-p7":0.0039,"2.4.7-p8":0.0037,"2.4.7-p9":0.0024,"2.4.8":0.0028,"2.4.8-p1":0.0036,"2.4.8-p2":0.0042,"2.4.8-p3":0.0044,"2.4.8-p4":0.0047,"2.4.8-p5":0.004,"2.4.9":0.0043,"unspecified":0.0064},"confidence":0.4581},"backportWorthy":{"score":1.483,"probabilities":{"0":0.1011,"1":0.3148,"2":0.5841},"confidence":0.1757}},"curated":{"title":"Related, upsell and cross-sell queries prevent the indexer from renaming tables","description":"The related, upsell and cross-sell blocks run a non optimized query with a double join; on MariaDB versions 10.4-10.6 these long running queries prevent the indexer from renaming the tables. When out of stock products are not shown, the CatalogInventory ProductLinks plugin now uses addIsInStockFilterToCollection, not addInStockFilterToCollection, which the PR says removes the double join.","categories":["Performance"],"author":"claude-code/opus-5.5","date":"2026-10-06","reviewedBy":null},"tests":{"2.4.7-p10":{"before":"fail","after":"pass","adapted":false,"runAt":"2026-10-06T09:29:05.396Z","releaseCommit":"72561bf80652f57cc642a03e2c9a51d74a285b14","suites":{"unit":{"before":"fail","after":"pass","runAt":"2026-10-06T09:29:05.396Z"}}}}},"_documentation":"https://magento.watch/api","_description":"Upstream fix magento2-38050 details"}