MySQL InnoDB 简单 SELECT 查询需要 0.2 秒

MySQL InnoDB simple SELECT query takes 0.2 seconds

我有一些 table:

mysql> show columns from room_lesson;
+-------------------------+--------------+------+-----+---------+----------------+
| Field                   | Type         | Null | Key | Default | Extra          |
+-------------------------+--------------+------+-----+---------+----------------+
| id                      | int          | NO   | PRI | NULL    | auto_increment |
  ...
  <skipped>
  ...
| online_users_count      | int          | NO   |     | NULL    |                |
+-------------------------+--------------+------+-----+---------+----------------+

和简单的SELECT查询:

SELECT count(*) FROM room_lesson WHERE online_users_count = 2;

执行需要 0.2 秒。

room_lesson table 大小为 1.3 Gb。

我怎样才能加快这个查询?

对于这个查询:

SELECT count(*) FROM room_lesson WHERE online_users_count = 2;

最优索引在:

CREATE INDEX idx_room_lesson_online_users_count on room_lesson(online_users_count)

但是,索引加快查询速度的多少取决于计数的频率 2 以及 table 中行的宽度。应该会有改善,但可能不会很明显(例如,50% 而不是 99%)。