该表有大约 1700 万行,是 MyISAM。
select DateModified,PELTM,PSLTM
from financial_key_ratios
where SecurityId = 4525
and DateModified >= '2015-01-07';
Run Code Online (Sandbox Code Playgroud)
这个简单的查询似乎需要超过 1 秒的时间。
索引似乎没问题。这是解释的输出:
explain
select DateModified,PELTM,PSLTM
from financial_key_ratios
where SecurityId = 4525
and DateModified >= '2015-01-07';
+----+-------------+----------------------+-------+------------------------------------------------+------------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------------+-------+------------------------------------------------+------------+---------+------+------+-------------+
| 1 | SIMPLE | financial_key_ratios | range | SecurityId,secid,DateModified_index,secid_date | secid_date | 7 | NULL | 156 | Using where |
+----+-------------+----------------------+-------+------------------------------------------------+------------+---------+------+------+-------------+
Run Code Online (Sandbox Code Playgroud)
我们可能做错了什么? …