【发布时间】:2019-10-26 16:55:12
【问题描述】:
我的查询在索引上花费了太多时间。 如何为我的 Mysql 查询创建一个好的索引?
查询
SELECT `id`, `time`, `volume`, `candle` FROM `forex_history`
WHERE
period='30m' AND
id IN ('40','1817')
ORDER BY `time` DESC
LIMIT 600;
表格中有 9500 万行
慢查询日志:
# Query_time: 3.801843 Lock_time: 0.000076 Rows_sent: 600 Rows_examined: 10966
# Rows_affected: 0 Bytes_sent: 49296
10% 的查询速度很慢。 查询需要 0.2 秒到 30 秒
表架构:
执行计划:
【问题讨论】:
-
运行
explain select ...查看执行计划。 -
我今天才学习“解释选择...”,你能帮我检查一下它的结果吗..谢谢。截图prntscr.com/pooyu7
标签: mysql