mysql对于innodb的count(*) 以及count(1)测试比较
数据表200多w记录
测试环境1(master db)
4核志强CPU
内存15G
- mysql> select count(*) from articles;
- +----------+
- | count(*) |
- +----------+
- | 2871704 |
- +----------+
- 1 row in set (35.31 sec)
测试环境2(slave db)
AMD 双核
内存8G
- mysql> select count(1) from articles;
- +----------+
- | count(1) |
- +----------+
- | 2871704 |
- +----------+
- 1 row in set (2.71 sec)
- mysql> select count(1) from articles;
- +----------+
- | count(1) |
- +----------+
- | 2871704 |
- +----------+
- 1 row in set (0.00 sec)
看来count(1)和count(*) 还是有区别的阿…
This entry was posted on 星期四, 十二月 24th, 2009 at 11:17 上午 and is filed under mysql. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
小黑 十二月 25th, 2009 at 9:18 上午
@LINVO
myisam 对于count(*) 似乎有优化,昨天请朋友测试了下 400w+的记录,两则执行时间相当,几乎没差