MYSQL benchmark function is one of the most important functions, the use of the function is analyzed in detail below, if you are interested in this, you may wish to see.
The following is a description of the MySQL benchmark function syntax, and some of the MySQL benchmark function related questions to test, for your reference to learn.
- BENCHMARK (count,expr)
- The BENCHMARK () function repeats counttimes execution of the expression expr, which can be used to time how fast the MySQL processing expression is. The result value is always 0. Intended for MySQL clients, it reports the execution time of the query.
- MySQL> select BENCHMARK (1000000,encode ("Hello", "Goodbye"));
- +----------------------------------------------+
- | BENCHMARK (1000000,encode ("Hello", "Goodbye")) |
- +----------------------------------------------+
- | 0 |
- +----------------------------------------------+
- 1 row in Set (4.74 sec)
The reported time is the client's elapsed time, not the CPU time on the server side. It may be advisable to execute benchmark () several times, and note that the load on the server machine is multiple to interpret the results.
--------------------------------------------------------------------------------
As long as we set the parameter count to a larger point, the execution time will be longer. Let's take a look at the effect in MySQL:
- MySQL> select MD5 (' Test ');
- +----------------------------------+
- | MD5 (' Test ') |
- +----------------------------------+
- | 098f6bcd4621d373cade4e832627b4f6 |
- +----------------------------------+
- 1 row in Set (0.00 sec)-----------Execution Time is 0.00 sec
- MySQL> select benchmark (500000, MD5 (' Test '));
- +------------------------------------+
- | Benchmark (500000, MD5 (' Test ')) |
- +------------------------------------+
- | 0 |
- +------------------------------------+
- 1 row in Set (6.55 sec)------------Execution Time is 6.55 sec
This shows that the time to execute 500,000 times with benchmark is significantly longer than the normal execution time.
The above is an introduction to the use of MySQL benchmark functions.
The use of MYSQL benchmark functions