The following describes the syntax of the mysql benchmark function and some tests on the mysql benchmark function.
- BENCHMARK (count, expr)
- The BENCHMARK () function repeats the countTimes execution expression expr, which can be used to time how fast the MySQL processing expression is. The result value is always 0. Intended for mysql customers, it reports the query execution time.
- Mysql> select BENCHMARK (1000000, encode ("hello", "goodbye "));
- + ---------------------------------------------- +
- | BENCHMARK (1000000, encode ("hello", "goodbye") |
- + ---------------------------------------------- +
- | 0 |
- + ---------------------------------------------- +
- 1 row in set (4.74 sec)
The report time is the client time, not the CPU time on the server. It may be wise to execute BENCHMARK () several times, and note that the server load has to be explained again.
--------------------------------------------------------------------------------
As long as we set the count parameter to a greater value, the execution time will become longer. Next we will look at the effect of execution in mysql:
- Mysql> select md5 ('test ');
- + ---------------------------------- +
- | Md5 ('test') |
- + ---------------------------------- +
- | 098f6bcd4621d373cade4e832627b4f6 |
- + ---------------------------------- +
- 1 row in set (0.00 sec) <----------- the execution time is 0.00 sec
-
- Mysql> select benchmark (500000, md5 ('test '));
- + ------------------------------------ +
- | Benchmark (500000, md5 ('test') |
- + ------------------------------------ +
- | 0 |
- + ------------------------------------ +
- 1 row in set (6.55 sec) <------------ the execution time is 6.55 sec
It can be seen that the time for executing 500000 times with benchmark is significantly longer than the normal execution time.
The preceding section describes how to use the mysql benchmark function.
Mysql Aggregate functions
MySQL string case-sensitive Conversion Function
Use of the concat_ws function in MySQL
Syntax for creating a Mysql trigger
Implementation of MySql remote connection