[Opencart] Optimize SQL query

Job ID: 30888545

Budget: €8 – €30 EUR

We have a Opencart project with more than 500k products.
Each product have at least 4 / 5 attributes, so the product_attribute table have almost 2 millon registers.

We use Journal2 theme, and super_filter module in category page in order to filter by attributes.

Actually, it spent more tan 10s to load a category page.

Its the SQL query what need to optimize:

SELECT
pa.product_id,
MAX(agd.attribute_group_id) as attribute_group_id,
MAX(agd.name) as attribute_group_name,
MAX(a.attribute_id) as attribute_id,
MAX(ad.name) as attribute_name,
MAX(pa.text) text,
COUNT(*) total
FROM `col_product_attribute` pa
LEFT JOIN `col_attribute` a ON a.attribute_id = pa.attribute_id
LEFT JOIN `col_attribute_description` ad ON ad.attribute_id = a.attribute_id
LEFT JOIN `col_attribute_group_description` agd ON agd.attribute_group_id = a.attribute_group_id
LEFT JOIN `col_product_to_category` p2c ON p2c.product_id = pa.product_id
LEFT JOIN `col_product` p ON p.product_id = pa.product_id
WHERE pa.product_id > 0
AND pa.attribute_id IN (187,214)
AND p2c.category_id = '424'
AND HOUR(p.image_date) = '9'
AND ad.language_id = '1'
AND agd.language_id = '1'
GROUP BY lower(pa.text), a.attribute_id
HAVING COUNT(*) > 0


IMPORTANT:
In order to ensure you have read the project and evaluate your offer, please paste this code at the start of your proporsal: OCSQLOPT

Thank you
Related categories: PHP SQL eCommerce MySQL Open Cart