【发布时间】:2011-12-24 17:20:18
【问题描述】:
我有这个 mysql 查询,但我不确定索引查询中的所有字段的含义是什么。我的意思是可以索引 CASE 语句、Join 语句和 Where 语句中的所有字段吗?索引字段是否会对性能产生影响?
SELECT roots.id as root_id, root_words.*,
CASE
WHEN root_words.title LIKE '%text%' THEN 1
WHEN root_words.unsigned_title LIKE '%normalised_text%' THEN 2
WHEN unsigned_source LIKE '%normalised_text%' THEN 3
WHEN roots.root LIKE '%text%' THEN 4
END as priorities
FROM roots INNER JOIN root_words ON roots.id=root_words.root_id
WHERE (root_words.unsigned_title LIKE '%normalised_text%') OR (root_words.title LIKE '%text%')
OR (unsigned_source LIKE '%normalised_text."%') OR (roots.root LIKE '%text%') ORDER by priorities
还有,如何进一步提高上述查询的速度?
谢谢!
【问题讨论】:
标签: mysql sql performance select indexing