medyczny Posted November 12, 2020 Share Posted November 12, 2020 Czesc. Dostałem informację od firmy hostingowej, że Problem z zapytaniem do bazy danych, który powoduje 100% użycia CPU na serwerze MySQL powraca. Czy może mi ktoś podpowiedzieć gdzie może leżeć problem ? Zapytanie które powoduje błąd to : SELECT COUNT(DISTINCT p.id_product) c FROM (SELECT p.id_product, p.id_manufacturer, SUM(sa.quantity) as quantity, p.condition, p.weight, p.price, psales.quantity as sales, cp.position FROM ps_product p LEFT JOIN ps_product_attribute pa ON (p.id_product = pa.id_product) LEFT JOIN ps_product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute) LEFT JOIN ps_stock_available sa ON (p.id_product = sa.id_product AND IFNULL(pac.id_product_attribute, 0) = sa.id_product_attribute AND sa.id_shop = 1 AND sa.id_shop_group = 0 ) LEFT JOIN ps_product_sale psales ON (psales.id_product = p.id_product) INNER JOIN ps_category_product cp ON (p.id_product = cp.id_product) INNER JOIN ps_category c ON (cp.id_category = c.id_category AND c.active=1) INNER JOIN ps_product_shop ps ON (p.id_product = ps.id_product AND ps.id_shop = 1 AND ps.active = TRUE) WHERE p.visibility IN ('both', 'catalog') AND c.nleft>=353 AND c.nright<=386 AND ps.id_shop='1' GROUP BY p.id_product) p LEFT JOIN ps_product_attribute pa ON (p.id_product = pa.id_product) LEFT JOIN ps_product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute) LEFT JOIN ps_stock_available sa ON (p.id_product = sa.id_product AND IFNULL(pac.id_product_attribute, 0) = sa.id_product_attribute AND sa.id_shop = 1 AND sa.id_shop_group = 0 ) LEFT JOIN ps_stock_available sa_1 ON (p.id_product = sa_1.id_product AND IFNULL(pac.id_product_attribute, 0) = sa_1.id_product_attribute AND sa_1.id_shop = 1 AND sa_1.id_shop_group = 0 ) WHERE ((sa.quantity<=0 AND sa_1.out_of_stock IN (0, 2))) Link to comment Share on other sites More sharing options...
endriu107 Posted November 12, 2020 Share Posted November 12, 2020 Coś mi się wydaje że już Ci kiedyś zwróciłem uwagę co do publikacji tematów w właściwych działach. Temat zamykam zły dział. Link to comment Share on other sites More sharing options...
Recommended Posts