Всем привет. Уважаемые форумчане помогите разобраться. Вот такие медленые запросы как от них избавиться. Спасибо.
Запрос 1.
SELECT a.attribute_group_id AS group_id, av.attribute_id AS attr_id, av.attribute_value_id AS val_id, agd.name AS group_name, ad.name AS attr_name, av.value FROM `oc_bf_aggregate_filters` AS af INNERJOIN ( SELECT p.* FROM `oc_product` AS p INNER JOIN `oc_product_to_category` AS p2c ON(p.product_id = p2c.product_id) INNER JOIN `oc_category_path` AS cp ON (cp.category_id = p2c.category_id) WHERE cp.path_id = '11') AS p ON (af.product_id = p.product_id) INNER JOIN`oc_bf_attribute_value` AS av ON (af.value = av.attribute_value_id) INNER JOIN `oc_attribute` AS a ON(a.attribute_id = av.attribute_id) INNER JOIN `oc_attribute_description` AS ad ON (ad.attribute_id = a.attribute_id) INNER JOIN `oc_attribute_group` AS ag ON (ag.attribute_group_id = a.attribute_group_id)INNER JOIN `oc_attribute_group_description` AS agd ON (agd.attribute_group_id = a.attribute_group_id)INNER JOIN `oc_product_to_store` AS ps ON (p.product_id = ps.product_id) WHERE agd.language_id ='2' AND ad.language_id = '2' AND av.language_id = '2' AND ps.store_id = '0' AND af.type = 'ATTRIBUTE'GROUP BY av.attribute_value_id ORDER BY ag.sort_order, ag.attribute_group_id, a.sort_order, ad.name, av.sort_order, av.value
Запрос 2.
SELECT p.product_id, (SELECT AVG(rating) AS total FROM oc_review r1 WHERE r1.product_id = p.product_id AND r1.STATUS = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROMoc_product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '1' ANDpd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) ASdiscount, (SELECT price FROM oc_product_special ps WHERE ps.product_id = p.product_id ANDps.customer_group_id = '1' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND(ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT1) AS special FROM oc_product p LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) WHEREpd.language_id = '2' AND p.STATUS = '1' AND p.date_available <= NOW() AND p2s.store_id = '0'GROUP BY p.product_id ORDER BY p.date_added DESC, LCASE(pd.name) DESC LIMIT 0,4
Запрос 3.
INSERT IGNORE INTO `oc_bf_aggregate_filters` (type,group_id,product_id,value) SELECT 'ATTRIBUTE', av.attribute_id, product_id, attribute_value_id FROM `oc_bf_tmp` AS pa LEFT JOIN`oc_bf_attribute_value` AS av ON (pa.value = av.value AND av.language_id = pa.language_id ANDav.attribute_id = pa.attribute_id) WHERE av.value IS NOT NULL