我的查询出现问题,他们需要很长时间才能获得产品结果。我只在主表中有13,000条记录,然后链接到其他一些表,这些表主要是属性表,里面有十几条记录
我之前使用过索引,但只在一个表上使用查询而不在其他地方加入。
这是我的查询
SELECT
product_data.id AS id,
product_data.sku AS sku,
product_data.barcode AS barcode,
product_data.title AS title,
product_data.attrib_releasedate AS attrib_releasedate,
product_category_main.id AS category_main_id,
product_category_main.name AS category_main_description,
product_category_sub.id AS category_sub_id,
product_category_sub.name AS category_sub_description,
product_category_sub.description_short AS category_sub_description_short,
product_condition.id AS condition_id,
product_condition.name AS condition_description,
attrib_pegi.name AS attrib_pegi,
attrib_region.name AS attrib_region,
product_data.asin AS asin,
product_data.cex AS cex
FROM product_data
INNER JOIN product_category_main
ON product_data.category_main_id = product_category_main.id
INNER JOIN product_category_sub
ON product_data.category_sub_id = product_category_sub.id
LEFT JOIN product_condition
ON product_data.condition_id = product_condition.id
LEFT JOIN attrib_pegi
ON attrib_pegi.id = product_data.attrib_pegi
LEFT JOIN attrib_region
ON attrib_region.id = product_data.attrib_region
WHERE
title<>'' AND product_category_main.id = 1
ORDER BY
category_main_id, title