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

SYS_EXTERNAL_QUERY_DETAIL

使用 SYS_EXTERNAL_QUERY_DETAIL 查看段级别查询的详细信息。每行代表来自特定 WLM 查询的一段,其中包含 Amazon S3 中处理的行数、处理的字节数以及外部表的分区信息等详细信息。此视图除了具有与外部查询处理相关的更多详细信息之外,每一行还将在 SYS_QUERY_DETAIL 视图中有一个相应条目。

SYS_EXTERNAL_QUERY_DETAIL 对所有用户可见。超级用户可以查看所有行;普通用户只能查看其自己的数据。有关更多信息,请参阅 系统表和视图中的数据可见性

表列

列名称 数据类型 描述
user_id integer 提交查询的用户标识符。
query_id bigint 外部查询的查询标识符。
transaction_id bigint 事务标识符。
child_query_sequence integer 重写的用户查询的顺序。从 0 开始,类似于 segment_id。
segment_id integer 查询分段的分段标识符。
source_type character(32) 查询的数据源类型,可能是针对 Redshift Spectrum 的 S3、针对联合查询的 PG
start_time timestamp 查询开始的时间。
end_time timestamp 查询完成的时间。
duration bigint 在查询上花费的时间(微秒)。
total_partitions integer Amazon S3 查询所需的分区数。
qualified_partitions integer Amazon S3 查询扫描的分区数。
scanned_file bigint 扫描的 Amazon S3 文件数。
returned_rows bigint Amazon S3 查询的扫描行数,或联合查询返回的行数。
returned_bytes bigint Amazon S3 查询的扫描字节数或联合查询返回的字节数。
file_format 文本 Amazon S3 文件的文件格式。
file_location 文本 外部表的 Amazon S3 位置。
external_query_text 文本 联合查询的段级查询文本。
warning_message character(4000) 查询运行的时候显示的警告消息。
table_name character(136) 正在操作的步骤的表名。
is_recursive character(1) 表示是否对子文件夹进行递归扫描。
is_nested character(1) 表示是否访问嵌套列数据类型。
s3list_time bigint 文件列出的持续时间(以毫秒为单位)。
get_paritition_time long 从 Amazon Glue Data Catalog 和 Apache Hive 中为给定的外部对象列出和限定分区所花费的时间。

示例查询

以下查询显示了外部查询详细信息。

SELECT query_id, segment_id, start_time, end_time, total_partitions, qualified_partitions, scanned_files, returned_rows, returned_bytes, trim(external_query_text) query_text, trim(file_location) file_location FROM sys_external_query_detail ORDER BY query_id, start_time DESC LIMIT 2;

示例输出。

query_id | segment_id | start_time | end_time | total_partitions | qualified_partitions | scanned_files | returned_rows | returned_bytes | query_text | file_location ----------+------------+----------------------------+----------------------------+------------------+----------------------+---------------+---------------+----------------+------------+--------------- 763251 | 0 | 2022-02-15 22:32:23.312448 | 2022-02-15 22:32:24.036023 | 3 | 3 | 3 | 38203 | 2683414 | | 763254 | 0 | 2022-02-15 22:32:40.17103 | 2022-02-15 22:32:40.839313 | 3 | 3 | 3 | 38203 | 2683414 | |