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

STL_LIMIT

分析在 SELECT 查询中使用 LIMIT 子句时发生的执行步骤。

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

注意

STL_LIMIT 仅包含在主集群上运行的查询。它不包含在并发扩展集群上运行的查询。要访问在主集群和并发扩展集群上运行的查询,我们建议您使用 SYS 监控视图 SYS_QUERY_DETAIL。SYS 监控视图中的数据经过格式化处理,便于使用和理解。

表列

列名称 数据类型 描述
userid integer 生成该条目的用户 ID。
query integer 查询 ID。查询列可用于连接其他系统表和视图。
slice integer 标识运行查询所在切片的标识符。
segment integer 标识查询区段的数字。
step integer 运行的查询步骤。
starttime 时间戳 查询开始的时间(采用 UTC 表示)。总时间包括排队和执行时间。秒的小数部分以 6 位精度表示。例如:2009-06-12 11:29:19.131358
endtime 时间戳 查询完成的时间(采用 UTC 表示)。总时间包括排队和执行时间。秒的小数部分以 6 位精度表示。例如:2009-06-12 11:29:19.131358
tasknum 整数 分配用于运行步骤的查询任务进程的数量。
rows bigint 处理的总行数。
checksum bigint 此信息仅供内部使用。

示例查询

为了在 STL_LIMIT 中生成行,此示例首先使用 LIMIT 子句对 VENUE 表运行了以下查询。

select * from venue order by 1 limit 10;
venueid | venuename | venuecity | venuestate | venueseats ---------+----------------------------+-----------------+------------+------------ 1 | Toyota Park | Bridgeview | IL | 0 2 | Columbus Crew Stadium | Columbus | OH | 0 3 | RFK Stadium | Washington | DC | 0 4 | CommunityAmerica Ballpark | Kansas City | KS | 0 5 | Gillette Stadium | Foxborough | MA | 68756 6 | New York Giants Stadium | East Rutherford | NJ | 80242 7 | BMO Field | Toronto | ON | 0 8 | The Home Depot Center | Carson | CA | 0 9 | Dick's Sporting Goods Park | Commerce City | CO | 0 10 | Pizza Hut Park | Frisco | TX | 0 (10 rows)

然后,运行以下查询来查找您已对 VENUE 表运行的最后一个查询的查询 ID。

select max(query) from stl_query;
max -------- 127128 (1 row)

或者,您可以运行以下查询来验证查询 ID 是否对应于之前运行的 LIMIT 查询。

select query, trim(querytxt) from stl_query where query=127128;
query | btrim --------+------------------------------------------ 127128 | select * from venue order by 1 limit 10; (1 row)

最后,运行以下查询来返回有关 STL_LIMIT 表中的 LIMIT 查询的信息。

select slice, segment, step, starttime, endtime, tasknum from stl_limit where query=127128 order by starttime, endtime;
slice | segment | step | starttime | endtime | tasknum -------+---------+------+----------------------------+----------------------------+--------- 1 | 1 | 3 | 2013-09-06 22:56:43.608114 | 2013-09-06 22:56:43.609383 | 15 0 | 1 | 3 | 2013-09-06 22:56:43.608708 | 2013-09-06 22:56:43.609521 | 15 10000 | 2 | 2 | 2013-09-06 22:56:43.612506 | 2013-09-06 22:56:43.612668 | 0 (3 rows)