MySQL的benchmark函数
上一篇:Oracle11g部分新特性移植到9i和10g 下一篇:编写插件修改Wordpress的RSS输出

MySQL的benchmark函数

MySQL实现了很多独特的函数,有时候使用起来是非常的方便,或许这就是开源的好处吧。这里记录一下benchmark函数,一个用于测试MySQL函数性能的函数。benchmark函数只有两个参数,第一个是执行次数,第二个是要测试的函数或者表达式。返回的结果始终是0,执行时间才是我们需要的结果:

mysql> select benchmark(1e8,current_date());
+-------------------------------+
| benchmark(1e8,current_date()) |
+-------------------------------+
|              0 |
+-------------------------------+
1 row in set (31.08 sec)

mysql> select benchmark(1e8,abs(1));           
+-----------------------+
| benchmark(1e8,abs(1)) |
+-----------------------+
|          0 |
+-----------------------+
1 row in set (1.31 sec)

除法的效率明显不如乘法:

mysql> select benchmark(1e8,1*1); 
+--------------------+
| benchmark(1e8,1*1) |
+--------------------+
|        0 |
+--------------------+
1 row in set (1.45 sec)

mysql> select benchmark(1e8,1/1); 
+--------------------+
| benchmark(1e8,1/1) |
+--------------------+
|        0 |
+--------------------+
1 row in set (19.47 sec)

本文网址:http://www.ningoo.net/html/2008/mysql_benchmark_function.html

订阅到Google | 收藏到Del.icio.us | 推荐到鲜果

相关文章 随机文章

本文Tags: , ,

没有评论


(Required)
(Required, will not be published)