8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 10 优化 / 10.13 测量性能(基准测试) / 10.13.1 测量表达式和函数的速度
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

10.13.1 测量表达式和函数的速度10.13.1 Measuring the Speed of Expressions and Functions

要测量特定 MySQL 表达式或函数的速度,可以使用 BENCHMARK() 函数,通过 mysql 客户端程序调用。其语法为 BENCHMARK(loop_count,expr)。返回值总是零,但 mysql 会打印一行,大致显示语句执行所花费的时间。例如:To measure the speed of a specific MySQL expression or function, invoke the BENCHMARK() function using the mysql client program. Its syntax is BENCHMARK(loop_count,expr). The return value is always zero, but mysql prints a line displaying approximately how long the statement took to execute. For example:

mysql> SELECT BENCHMARK(1000000,1+1);
+------------------------+
| BENCHMARK(1000000,1+1) |
+------------------------+
|                      0 |
+------------------------+
1 row in set (0.32 sec)

这个结果是在一台 Pentium II 400MHz 系统上获得的。它显示 MySQL 在该系统上可以在 0.32 秒内执行 1,000,000 个简单的加法表达式。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.

内置的 MySQL 函数通常经过高度优化,但可能有一些例外。BENCHMARK() 是一个很好的工具,用于判断某些函数是否会影响你的查询性能。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.