文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

10.15.1 常用用法10.15.1 Typical Usage

执行优化器跟踪包括以下步骤:To perform optimizer tracing entails the following steps:

  1. 通过执行 SET optimizer_trace="enabled=ON" 来启用跟踪。Enable tracing by executing SET optimizer_trace="enabled=ON".

  2. 执行需要跟踪的语句。请参阅 第 10.15.3 节,“可跟踪语句”,了解可以跟踪的语句列表。Execute the statement to be traced. See Section 10.15.3, “Traceable Statements”, for a listing of statements which can be traced.

  3. 检查 INFORMATION_SCHEMA.OPTIMIZER_TRACE 表的内容。Examine the contents of the INFORMATION_SCHEMA.OPTIMIZER_TRACE table.

  4. 要检查多个查询的痕迹,请根据需要重复前两个步骤。To examine traces for multiple queries, repeat the previous two steps as needed.

  5. 完成后要禁用跟踪,请执行 SET optimizer_trace="enabled=OFF"。To disable tracing after you have finished, execute SET optimizer_trace="enabled=OFF".

您只能追踪当前会话中执行的语句;您无法查看其他会话的追踪。You can trace only statements which are executed within the current session; you cannot see traces from other sessions.