执行优化器跟踪包括以下步骤:To perform optimizer tracing entails the following steps:
通过执行
SEToptimizer_trace="enabled=ON"来启用跟踪。Enable tracing by executingSEToptimizer_trace="enabled=ON".执行需要跟踪的语句。请参阅 第 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.
检查
INFORMATION_SCHEMA.OPTIMIZER_TRACE表的内容。Examine the contents of theINFORMATION_SCHEMA.OPTIMIZER_TRACEtable.要检查多个查询的痕迹,请根据需要重复前两个步骤。To examine traces for multiple queries, repeat the previous two steps as needed.
完成后要禁用跟踪,请执行
SET optimizer_trace="enabled=OFF"。To disable tracing after you have finished, executeSET optimizer_trace="enabled=OFF".
您只能追踪当前会话中执行的语句;您无法查看其他会话的追踪。You can trace only statements which are executed within the current session; you cannot see traces from other sessions.