Tot*_*oto 6 mysql optimization full-text-search
当我在布尔搜索中更改关键字的顺序时,我得到相同的结果但性能结果却截然不同.
使用MyISAM表对MySQL 5.6.33进行概要分析,ft_min_word_len=2并将其description_index作为FULLTEXT索引title并description返回:
# Query 1
SELECT id
FROM archive, topic
WHERE topic.type=0 AND archive.status=2
AND MATCH(title, description) AGAINST ('+house* +tz*' IN BOOLEAN MODE)
AND archive.topicId = topic.id
ORDER BY archive.featured DESC, archive.submissionDate DESC LIMIT 0,20
Run Code Online (Sandbox Code Playgroud)
结果:
Total count: 12
Key_read_requests: 2384607
Creating sort index: 7.950430 sec (!)
Duration: 8.851252 sec
Run Code Online (Sandbox Code Playgroud)
# Query 2
SELECT id
FROM archive, topic
WHERE topic.type=0 AND archive.status=2
AND MATCH(title, description) AGAINST ('+tz* +house*' IN BOOLEAN MODE)
AND archive.topicId = topic.id
ORDER BY archive.featured DESC, archive.submissionDate DESC LIMIT 0,20
Run Code Online (Sandbox Code Playgroud)
结果:
Total count: 12
Key_read_requests: 415
Creating sort index: 0.003449
Duration: 0.004054 sec
Run Code Online (Sandbox Code Playgroud)
每个关键字的总记录:
tz*: 135092
tz: 25596
house*: 12
Run Code Online (Sandbox Code Playgroud)
两个查询的解释是相同的:
id | select_type | Table | Type | Key | Key len | Ref | Rows | Extra
1 | SIMPLE | archive | fulltext | description_index | 0 | | 1 | Using where; Using filesort
1 | SIMPLE | topic | eq_ref | PRIMARY | 3 | archive.topicId | 1 | Using where
Run Code Online (Sandbox Code Playgroud)
只有Key_read_requests和Creating sort index是2个查询之间的不同.
看起来:
问题:
| 归档时间: |
|
| 查看次数: |
257 次 |
| 最近记录: |