Name
BENCHMARK( )
Synopsis
BENCHMARK(number,expression)
Use this function to evaluate the performance of a MySQL server. The expression given as the second argument of the function is repeated for the number of times given in the first argument. The results are always 0. It's the processing time reported that is meaningful. This function is meant to be used from within the mysql client.
SELECT BENCHMARK(1000000,PI( )); +-------------------------+ | BENCHMARK(1000000,PI( )) | +-------------------------+ | 0 | +-------------------------+ 1 row in set (0.04 sec) SELECT BENCHMARK(1000000,PI( )); +-------------------------+ | BENCHMARK(1000000,PI( )) | +-------------------------+ | 0 | +-------------------------+ 1 row in set (0.02 sec)
In these two examples, the first SQL statement took .04 seconds and the second one took .02 seconds to determine the value of pi 1 million times. The difference is due to a variety of factors unrelated to the SQL statement. The function is useful when run several times to determine an average time before making changes to a server and then afterward to see the effect of the changes. For a much better performance indicator, try the Perl scripts provided in the sql-bench directory of the MySQL source files. For more information on these benchmark scripts, see High Performance MySQL (O'Reilly) by Jeremy D. Zawodny and Derek J. Balling.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access