请帮帮我,如何加快这个sql查询?
SELECT pa.*
FROM ParametrickeVyhladavanie pa,
(SELECT p.*
FROM produkty p
WHERE p.KATEGORIA IN ('$categoryArray')) produkt
WHERE produkt.ATTRIBUTE_CODE LIKE CONCAT('%', pa.code, '%')
AND produkt.ATTRIBUTE_VALUE LIKE CONCAT('%', pa.ValueCode, '%')
GROUP BY pa.code
索引:pa.code、pa.ValueCode、p.ATTRIBUTE_CODE、p.ATTRIBUTE_VALUE
显示第 0 - 25 行(共 26 行,查询耗时20.4995 秒)
编辑 实际代码:
SELECT pa.*
FROM ParametrickeVyhladavanie pa
WHERE EXISTS
(
SELECT 1 FROM produkty p
JOIN
PRODUCT_INFO AS pi
ON p.ProId = pi.ProduktID
AND p.KATEGORIA IN ('Mobily'))
AND pi.ATTRIBUTE_CODE = pa.AttributeCode
AND pi.ATTRIBUTE_VALUE = pa.ValueCode
GROUP BY pa.code
此代码显示错误#1054 - Unknown column 'pi.ATTRIBUTE_CODE' in 'where clause'
该pi.
表仅在(
和之间工作)
编辑 - 这是答案
我将 MySQL 5.1 更改为 MariaDB 5.5,而且速度更快!!!