【发布时间】:2012-07-28 12:32:48
【问题描述】:
SELECT * FROM items WHERE caption LIKE 'name%' AND type = 'private' OR owner LIKE 'name%' type = 'private' ORDER BY uses DESC LIMIT 40;
可能的键:items_caption、items_owner、items_type 键:items_uses (通过解释命令得到这些)
执行该查询大约需要 1.8 秒,并且表中有超过百万条记录。我不知道如何为这个查询创建索引,而且我无法控制源,所以我无法修改查询。
【问题讨论】:
-
LIKE 'name%'和type = 'private'之间缺少的运算符是什么 -
糟糕。这是与。 SELECT * FROM items WHERE caption LIKE 'name%' AND type = 'private' OR owner LIKE 'name%' AND type = 'private' ORDER BY 使用 DESC LIMIT 40;