SYS_QUERY_DETAIL - Amazon Redshift
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

SYS_QUERY_DETAIL

使用 SYS_QUERY_DETAILS 在步骤级别查看查询的详细信息。每一行代表特定 WLM 查询的一个步骤,其中包含详细信息。此视图包含许多类型的查询,例如 DDL、DML 和实用程序命令(例如:复制和卸载)。根据查询类型,某些列可能不相关。例如,external_scanned_bytes 与内部表无关。

注意

没有相应的重写查询的查询仅在 SYS_QUERY_HARISTISS 视图中具有条目,在 SYS_QUERY_DETAILS 视图没有条目。

SYS_QUERY_DETITIONS 对所有用户可见。超级用户可以查看所有行;普通用户只能查看其具有访问权限的元数据。

表列

列名称 数据类型 描述
user_id integer 提交查询的用户标识符。
query_id bigint 查询标识符。
child_query_sequence integer 重写的用户查询的顺序。从 0 开始,类似于 segment_id。
stream_id integer 查询流的流标识符。
segment_id integer 查询运行分段的分段标识符。
step_id integer 分段中的步骤标识符。
step_name text 分段中的步骤名称。例如,scan、hash、agg 等。
table_id integer 永久性表扫描的表标识符。
table_name character(136) 正在操作的步骤的表名。
is_rrsscan 字符 指示步骤是否为扫描步骤的值。True(t)则表示使用了限制范围的扫描。
start_time timestamp 查询步骤开始的时间。
end_time timestamp 查询步骤完成的时间。
duration bigint 在步骤上花费的时间(微秒)。
警报 text 提示事件的描述。
input_bytes bigint 当前步骤的输入字节。
input_rows bigint 当前步骤的输入行。
output_bytes bigint 当前步骤的输出字节。
output_rows bigint 当前步骤的输出行。
blocks_read bigint 步骤读取的数据块数。
blocks_write bigint 步骤写入的数据块数。
local_read_IO bigint 从本地磁盘缓存中读取的数据块的数量。
remote_read_IO bigint 从远程读取的数据块数。
data_skewness integer 所有步骤间输出行分布的偏度。这是一个介于 0% 到 100% 之间的数字。该数字越大,分布越不平衡。
time_skewness integer 所有步骤间执行时间分布的偏度。这是一个介于 0% 到 100% 之间的数字。该数字越大,分布越不平衡。

示例查询

以下示例返回了 SYS_QUERY_DETAIL 的输出。

以下查询显示了步骤级别的查询元数据详细信息,包括步骤名称、input_bytes、output_bytes、input_rows、output_rows。

SELECT query_id, child_query_sequence, stream_id, segment_id, step_id, trim(step_name) AS step_name, duration, input_bytes, output_bytes, input_rows, output_rows FROM sys_query_detail WHERE query_id IN (193929) ORDER BY query_id, stream_id, segment_id, step_id DESC;

示例输出。

query_id | child_query_sequence | stream_id | segment_id | step_id | step_name | duration | input_bytes | output_bytes | input_rows | output_rows ----------+----------------------+-----------+------------+---------+------------+-----------------+-------------+--------------+------------+------------- 193929 | 2 | 0 | 0 | 3 | hash | 37144 | 0 | 9350272 | 0 | 292196 193929 | 5 | 0 | 0 | 3 | hash | 9492 | 0 | 23360 | 0 | 1460 193929 | 1 | 0 | 0 | 3 | hash | 46809 | 0 | 9350272 | 0 | 292196 193929 | 4 | 0 | 0 | 2 | return | 7685 | 0 | 896 | 0 | 112 193929 | 1 | 0 | 0 | 2 | project | 46809 | 0 | 0 | 0 | 292196 193929 | 2 | 0 | 0 | 2 | project | 37144 | 0 | 0 | 0 | 292196 193929 | 5 | 0 | 0 | 2 | project | 9492 | 0 | 0 | 0 | 1460 193929 | 3 | 0 | 0 | 2 | return | 11033 | 0 | 14336 | 0 | 112 193929 | 2 | 0 | 0 | 1 | project | 37144 | 0 | 0 | 0 | 292196 193929 | 1 | 0 | 0 | 1 | project | 46809 | 0 | 0 | 0 | 292196 193929 | 5 | 0 | 0 | 1 | project | 9492 | 0 | 0 | 0 | 1460 193929 | 3 | 0 | 0 | 1 | aggregate | 11033 | 0 | 201488 | 0 | 14 193929 | 4 | 0 | 0 | 1 | aggregate | 7685 | 0 | 28784 | 0 | 14 193929 | 5 | 0 | 0 | 0 | scan | 9492 | 0 | 23360 | 292196 | 1460 193929 | 4 | 0 | 0 | 0 | scan | 7685 | 0 | 1344 | 112 | 112 193929 | 2 | 0 | 0 | 0 | scan | 37144 | 0 | 7304900 | 292196 | 292196 193929 | 3 | 0 | 0 | 0 | scan | 11033 | 0 | 13440 | 112 | 112 193929 | 1 | 0 | 0 | 0 | scan | 46809 | 0 | 7304900 | 292196 | 292196 193929 | 5 | 0 | 0 | -1 | | 9492 | 12288 | 0 | 0 | 0 193929 | 1 | 0 | 0 | -1 | | 46809 | 16384 | 0 | 0 | 0 193929 | 2 | 0 | 0 | -1 | | 37144 | 16384 | 0 | 0 | 0 193929 | 4 | 0 | 0 | -1 | | 7685 | 28672 | 0 | 0 | 0 193929 | 3 | 0 | 0 | -1 | | 11033 | 114688 | 0 | 0 | 0