从快照还原的AWS RDS使用复合索引非常慢

时间:2019-04-26 15:12:09

标签: mysql amazon-web-services amazon-rds snapshot composite-index

所以我有2个表,每个表都是25GB。

表t1在单个列上有一个索引,而t2在复合列上。
我所有的查询都是利用索引的简单查询。

我的t2表

CREATE TABLE `t2` (
  `uid` bigint(20) DEFAULT NULL,
  `time` bigint(20) DEFAULT NULL,
  `content` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  KEY `composite` (`uid`,`time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |

我的查询

explain select * from t2 where uid between 1 and 10000 and time between 11 and 10000000;

解释结果:

+----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-----------------------+
| id | select_type | table | partitions | type  | possible_keys | key       | key_len | ref  | rows | filtered | Extra                 |
+----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-----------------------+
|  1 | SIMPLE      | q3    | NULL       | range | composite     | composite | 18      | NULL | 2548 |    11.11 | Using index condition |
+----+-------------+-------+------------+-------+---------------+-----------+---------+------+------+----------+-----------------------+
1 row in set, 1 warning (0.19 sec)

我观察到的一件奇怪的事是,当我从快照还原数据库时,t2会以3000的延迟变得非常慢,而t1会在大约5分钟后变为正常(有100的延迟)。

我知道快照存储在s3中。但是为什么t1可以正常工作,而t2却超级慢?

更新:我手动检查,发现复合索引在那里。我怀疑我的t2综合指数甚至无法正常工作。

我不认为这是内存缓冲区的问题,否则,经过5分钟的密集查询测试后,t2应该会正常。

0 个答案:

没有答案