运行 Advisor 时,详细的输出会发送到
架构
中的heatwave_advisor_report
表
。sys
该heatwave_advisor_report
表是一个临时表。它包含 Advisor 上次执行的数据。数据仅可用于当前会话,并在会话终止或服务器关闭时丢失
顾问报告表查询示例
运行 Advisor 后可以查询该heatwave_advisor_report
表,如下例所示:
-
查看顾问警告信息:
SELECT log FROM sys.heatwave_advisor_report WHERE type="warn";
-
查看错误信息以防 Advisor 意外停止:
SELECT log FROM sys.heatwave_advisor_report WHERE type="error";
-
查看针对 Advisor 建议生成的 DDL 语句:
SELECT log->>"$.sql" AS "SQL Script" FROM sys.heatwave_advisor_report WHERE type = "sql" ORDER BY id;
-
将 Advisor 生成的 DDL 语句连接成一个可以复制和粘贴以执行的字符串。该
group_concat_max_len
变量以字节为单位设置GROUP_CONCAT()
函数的结果长度,以容纳可能很长的字符串。(默认group_concat_max_len
设置为 1024 字节。)SET SESSION group_concat_max_len = 1000000; SELECT GROUP_CONCAT(log->>"$.sql" SEPARATOR ' ') FROM sys.heatwave_advisor_report WHERE type = "sql" ORDER BY id;
-
JSON
以以下格式 检索 Query Insights 数据:SELECT log FROM sys.heatwave_advisor_report WHERE stage = "QUERY_INSIGHTS" AND type = "info";
-
以 SQL 表格式检索 Query Insights 数据:
SELECT log->>"$.query_id" AS query_id, log->>"$.session_id" AS session_id, log->>"$.query_text" AS query_text, log->>"$.runtime_estimated_ms" AS runtime_estimated_ms, log->>"$.runtime_executed_ms" AS runtime_executed_ms, log->>"$.comment" AS comment FROM sys.heatwave_advisor_report WHERE stage = "QUERY_INSIGHTS" AND type = "info" ORDER BY id;