在 mysql 命令行客户端中检查追踪可以通过 pager
less 命令(或你所在操作平台的等效命令)来简化。另一种方法是将追踪发送到文件,就像这里展示的那样:Examining a trace in the mysql command-line
client can be made less difficult using the pager
less command (or your operating platform's
equivalent). An alternative can be to send the trace to a file,
similarly to what is shown here:
SELECT TRACE INTO DUMPFILE file
FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
然后,你可以将此文件传递给支持 JSON 的文本编辑器或其他查看器,例如 适用于 Firefox 和 Chrome 的 JsonView 插件,它可以彩色显示对象,并允许展开或折叠对象。You can then pass this file to a JSON-aware text editor or other viewer, such as the JsonView add-on for Firefox and Chrome, which shows objects in color and allows objects to be expanded or collapsed.
INTO DUMPFILE 比 INTO
OUTFILE 更适合此用途,因为后者会转义换行符。如前所述,执行 end_markers_in_json 语句时,应确保 OFF 为 SELECT
INTO,以确保输出是有效的 JSON。INTO DUMPFILE is preferable to INTO
OUTFILE for this purpose, since the latter escapes
newlines. As noted previously, you should ensure that
end_markers_in_json is
OFFwhen executing the SELECT
INTO statement, so that the output is valid JSON.