我正在尝试优化下面的查询,但是我不知道该怎么做。我对查询优化知之甚少,但是key_len不就意味着它要搜索386,386行吗?cities表有10,053行,州只有27行。
SELECT c.city_name, s.state_name
FROM res_geo_cities AS c, res_geo_states AS s
WHERE c.id_state = s.id_state AND(
(
(c.metaphone_primary IN ($one,$two) OR c.metaphone_secondary IN ($one,$two)) AND
(s.metaphone_primary IN ($three,$four) OR s.metaphone_secondary IN ($three,$four))
) OR (
(c.metaphone_primary IN ($three,$four) OR c.metaphone_secondary IN ($three,$four)) AND
(s.metaphone_primary IN ($one,$two) OR s.metaphone_secondary IN ($one,$two))
))
LIMIT 50
下面是解释:
有没有人能帮我指一下正确的方向?
发布于 2010-12-08 07:59:14
这意味着您有两个密钥,每个密钥的长度为386。尝试使用具有'ON‘子句的联接重写此查询,而不是仅从多个表中进行选择。希望这能有所帮助。
https://stackoverflow.com/questions/4382878
复制相似问题