Spec-Zone .ru
спецификации, руководства, описания, API
|
To measure the speed of a specific MySQL expression or function, invoke the BENCHMARK()
function using the mysql client program. Its syntax is BENCHMARK(
. The return value is always zero, but mysql prints a line displaying approximately how long the
statement took to execute. For example: loop_count
,expression
)
mysql> SELECT BENCHMARK(1000000,1+1);
+------------------------+| BENCHMARK(1000000,1+1) |+------------------------+| 0 |+------------------------+1 row in set (0.32 sec)
This result was obtained on a Pentium II 400MHz system. It shows that MySQL can execute 1,000,000 simple addition expressions in 0.32 seconds on that system.
The built-in MySQL functions are typically highly optimized, but there may be some exceptions. BENCHMARK()
is an excellent tool for finding out if some function is a problem
for your queries.