I am debugging magento 2.3.1 before releasing it to production and I find that some products respond slowly and others make it faster. (then I will update it to 2.3.2)
In particular I have a query that takes 24 seconds to respond and I do not know what is wrong.
Can you help me ?
SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_flat_1` AS `e` INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0 INNER JOIN `catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 INNER JOIN `cataloginventory_stock_item` AS `at_inventory_in_stock` ON (at_inventory_in_stock.`product_id`=e.entity_id) AND ((at_inventory_in_stock.use_config_manage_stock = 0 AND at_inventory_in_stock.manage_stock=1 AND at_inventory_in_stock.is_in_stock=1) OR (at_inventory_in_stock.use_config_manage_stock = 0 AND at_inventory_in_stock.manage_stock=0) OR (at_inventory_in_stock.use_config_manage_stock = 1 AND at_inventory_in_stock.is_in_stock=1)) WHERE (e.entity_id IN((SELECT `cat`.`product_id` FROM `catalog_category_product` AS `cat` WHERE (cat.category_id IN('4', '40', '45'))))) AND (e.entity_id != '204031')
SELECT COUNT(DISTINCT e.entity_id) FROM
catalog_product_flat_1
ASe
INNER JOINcatalog_product_index_price
ASprice_index
ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0 INNER JOINcatalog_category_product_index_store1
AScat_index
ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 INNER JOINcataloginventory_stock_item
ASat_inventory_in_stock
ON (at_inventory_in_stock.product_id
=e.entity_id) AND ((at_inventory_in_stock.use_config_manage_stock = 0 AND at_inventory_in_stock.manage_stock=1 AND at_inventory_in_stock.is_in_stock=1) OR (at_inventory_in_stock.use_config_manage_stock = 0 AND at_inventory_in_stock.manage_stock=0) OR (at_inventory_in_stock.use_config_manage_stock = 1 AND at_inventory_in_stock.is_in_stock=1)) WHERE (e.entity_id IN((SELECTcat
.product_id
FROMcatalog_category_product
AScat
WHERE (cat.category_id IN('4', '40', '45'))))) AND (e.entity_id != '204031')