0
有沒有辦法獲得更好的性能。簡單查詢在Mysql中緩慢
select * from p_all where sec='0P00009S33' order by date desc
查詢花了0.1578秒。
表結構如下所示。該表中有超過100百萬條記錄。
+------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------------+------+-----+---------+-------+
| sec | varchar(10) | NO | PRI | NULL | |
| date | date | NO | PRI | NULL | |
| open | decimal(13,3) | NO | | NULL | |
| high | decimal(13,3) | NO | | NULL | |
| low | decimal(13,3) | NO | | NULL | |
| close | decimal(13,3) | NO | | NULL | |
| volume | decimal(13,3) | NO | | NULL | |
| unadjusted_close | decimal(13,3) | NO | | NULL | |
+------------------+---------------+------+-----+---------+-------+
EXPLAIN結果
+----+-------------+-----------+------+---------------+---------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+------+---------------+---------+---------+-------+------+-------------+
| 1 | SIMPLE | price_all | ref | PRIMARY | PRIMARY | 12 | const | 1731 | Using where |
+----+-------------+-----------+------+---------------+---------+---------+-------+------+-------------+
我如何可以加快此查詢?
索引字段秒 –
你預計它有多快?對於這樣的查詢,150毫秒對我來說聽起來不那麼糟糕。該查詢返回了多少行? –
你在抱怨,因爲0.1578秒很慢? – rationalboss