MySQL BENCHMARK() Function

The MySQL BENCHMARK() function executes the specified expression repeatedly the specified number of times.

BENCHMARK() Syntax

Here is the syntax of the MySQL BENCHMARK() function:

BENCHMARK(count, expr)

Parameters

count

Required. The number of times to execute the expression specified.

expr

Required. The expression to execute.

Return value

The BENCHMARK() function executes the specified expression the specified number of times and returns 0.

If the argument count is NULL, or a negative number of times is given, the BENCHMARK() function will return NULL.

BENCHMARK() Examples

The following example shows how to use the BENCHMARK() function repeat the function MD5('aaa') 10,000,000 times.

SELECT BENCHMARK(10000000, MD5('aaa'));
+---------------------------------+
| BENCHMARK(10000000, MD5('aaa')) |
+---------------------------------+
|                               0 |
+---------------------------------+
1 row in set (2.29 sec)