Benchmark function under mysql database

This function can easily test the performance of certain specific operations

用法:benchmark(时间,表达式)
mysql> select * from admin union select 1,benchmark(500000000,1>2),3;
+------+----------+----------+
| id   | username | password |
+------+----------+----------+
| 1    | admin    | 123      |
| 1    | 0        | 3        |
+------+----------+----------+
2 rows in set (4.24 sec)

The return value after execution is always 0, but the execution time can be judged by the time returned by the client.

Although the BENCHMARK() function is very convenient to use, it is not suitable for real benchmark testing, because it is difficult to understand what is really being tested, and only part of the entire execution cycle is tested.

Guess you like

Origin blog.csdn.net/p_utao/article/details/110122823