SELECT resumeid, FirstName, LastName, Mobile, State, EmailId, Role,
Skill, Relocation, EmpType, ImmType, TotalExp, Buzzwords
from Resume r
where DetailsCaptured='Y'
and resumeid IN (
SELECT resumeid FROM Resume_Attachment ra
WHERE MATCH (ResumeTextContent)
AGAINST ('+"quality"' in boolean mode) )
order by UpdatedDate desc
limit 100
答案 0 :(得分:1)
对于不相关的子查询,最好使用JOIN
而不是IN
或EXISTS
。无论如何,IN ( SELECT ... )
,至少在旧版本中,表现糟糕。
如果这是“lazy eval”的尝试,由于WHERE
中的额外测试,它将无效。
所以,我们只是简化查询:
SELECT resumeid, FirstName, LastName, Mobile, State, EmailId,
Role, Skill, Relocation, EmpType, ImmType, TotalExp, Buzzwords
FROM Resume r
WHERE DetailsCaptured='Y'
AND MATCH (ResumeTextContent) AGAINST ('+"quality"' in boolean mode) )
ORDER BY UpdatedDate desc
LIMIT 100
优化工具
FULLTEXT
查找 ;这很快,但可能会返回超过100 resumeid
个值; WHERE
的其余部分不匹配的任何内容 - DetailsCaptured ='Y'; ORDER BY
)你不会比这更快 - 除非你能“知道”“大多数”行包含“质量”。
答案 1 :(得分:0)
作为@O。琼斯评论说,不可能肯定地说出来。 索引详情捕获可能会提高您的性能,但大部分时间可能会由IN子句和全文搜索。
尝试以下替代方案。
SELECT resumeid, FirstName, LastName, Mobile, State, EmailId, Role, Skill, Relocation, EmpType, ImmType, TotalExp, Buzzwords
FROM Resume r
WHERE DetailsCaptured='Y'
AND EXISTS (SELECT resumeid FROM Resume_Attachment ra WHERE ra.resumeid=r.resumeid AND ResumeTextContent LIKE '%quality%' COLLATE utf8_general_ci)
ORDER BY UpdatedDate DESC LIMIT 100