最近有一个project是优化mysql的效率。
首先是select count(*) 和select(id)
mysql> select count(*) from nim_acl_action;
+----------+
| count(*) |
+----------+
| 2230164 |
+----------+
1 row in set (20.73 sec)
mysql> select count(id) from nim_acl_action;
+-----------+
| count(id) |
+-----------+
| 2230164 |
+-----------+
1 row in set (8.61 sec)
相差效率1.5倍
首先是select count(*) 和select(id)
mysql> select count(*) from nim_acl_action;
+----------+
| count(*) |
+----------+
| 2230164 |
+----------+
1 row in set (20.73 sec)
mysql> select count(id) from nim_acl_action;
+-----------+
| count(id) |
+-----------+
| 2230164 |
+-----------+
1 row in set (8.61 sec)
相差效率1.5倍