SELECT
sql_no_cache
COUNT(p.id)
FROM shop_products p
LEFT OUTER JOIN shop_currency currency ON (p.currencyId=currency.id)
INNER JOIN shop_l2p l2p2 FORCE INDEX(show2) ON (p.id=l2p2.pid and l2p2.status>0)
INNER JOIN shop_labels l2 ON (l2p2.lid=l2.id and l2.type=2 and l2.status=1)
LEFT JOIN shop_l2p l2p3 ON (p.id=l2p3.pid and l2p3.status=1)
LEFT JOIN shop_labels l3 ON (l2p3.lid=l3.id and l3.type=3 and l3.status=1)
WHERE
CONCAT(p.label,l3.label,l2.label,p.stockCode) LIKE '%moda%'
AND p.status='1' A
ND p.stockAmount<>0
AND p.isOption=0
limit 1;
+-------------+
| COUNT(p.id) |
+-------------+
| 6669 |
+-------------+
1 row in set (3.91 sec)
有不同的想法?计数时间过长
你有什么指标对这些表?查询的执行计划是什么? – andri 2011-03-01 09:49:44
您是否创建了索引? 'LIKE“%MODA%”'如果搜索字符串包含''%在前面的索引将无法正常工作 – 2011-03-01 09:50:33
我想你也应该存在,你有指标,也许你以前多少条记录已经和更explicative – 2011-03-01 09:50:54