我创建了一个网站,使用颜色,品牌等过滤器展示产品,网站上有大约350万种产品。我需要一个mysql优化查询。我的数据库表结构/查询如下所述:
Products table :- (product_id, title, color_id, filter1_id, filter2_id)
Category table :- (category_id title, parent_id)
Product_price :- (id,product_id,mrp,price)
Filter table :- (filter_id, filter_title)
Filter Mapping table :-(filter_id, filter_map_id, filter_type)
Color table :- (color_id, color_title)
Size table :- (id, size_title, product_id)
查询:
SELECT
p.product_id,
p.store_id,
p.product_deepurl,
p.product_title,
p.img1,
p.product_brand,
pp.mrp,
pp.price
FROM
product as p
INNER JOIN
product_title as ps ON p.product_id = ps.product_id
INNER JOIN
product_price as pp ON p.product_id = pp.product_id
INNER JOIN
product_filter as f ON p.brand_id = f.filter_id
INNER JOIN
colors as c ON p.color_id = c.color_id
INNER JOIN
category as ct ON p.cat_id = ct.cat_id
WHERE
p.approved = 1
GROUP BY p.product_id
ORDER BY p.product_order ASC
LIMIT limitstart , 20
此查询运行,显示视图需要9到12秒。请仔细阅读并提供解决方案或提供一些替代方案
我们需要基于产品列表的网站的Mysql Optimize Query。