【发布时间】:2021-10-28 16:08:10
【问题描述】:
我有一些桌子:
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 表大小为 1.3 Gb。
如何加快查询速度?
【问题讨论】:
-
为
online_users_count添加索引
标签: mysql sql query-optimization