【发布时间】:2017-02-15 11:10:56
【问题描述】:
Table type: MyISAM
Rows: 120k
Data Length: 30MB
Index Length: 40MB
my.ini,MySQL 5.6.2 Windows
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
Windows Server 2012,12GB RAM,SSD 400MB/s
1 慢查询:
SELECT article_id, title, author, content, pdate, MATCH(author, title, content)
AGAINST('Search Keyword') AS score FROM articles ORDER BY score DESC LIMIT 10;
执行此查询需要 352 毫秒使用索引。 profiling 后,显示大部分时间都花在了创建排序索引上。 (完整详情:http://pastebin.com/raw/jT58DCN5)
2 更快的查询:
SELECT article_id, title, author, content, pdate, MATCH(author, title, content)
AGAINST('Search Keyword') AS score FROM articles LIMIT 10;
执行此查询需要 23ms 并进行全表扫描,我不喜欢全表扫描。
问题/疑问是,查询 #1 是我需要使用的,因为排序非常重要。
我能做些什么来加快查询/重写它并获得相同的结果(如 #1)?
感谢任何意见和帮助。
【问题讨论】:
标签: mysql performance query-optimization