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