

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# STL\_LOAD\_COMMITS
<a name="r_STL_LOAD_COMMITS"></a>

返回用于跟踪或排查数据加载的信息。

此视图记录了在每个数据文件加载到数据库表中时的进度。

STL\_LOAD\_COMMITS 对所有用户可见。超级用户可以查看所有行；普通用户只能查看其自己的数据。有关更多信息，请参阅 [系统表和视图中的数据可见性](cm_chap_system-tables.md#c_visibility-of-data)。

**注意**  
STL\_LOAD\_COMMITS 仅包含在主预置集群上运行的查询。它不包含在并发扩展集群或无服务器命名空间上运行的查询。要访问在主集群、并发扩展集群和无服务器命名空间上运行的查询的解释计划，我们建议您使用 SYS 监控视图 [SYS\_LOAD\_DETAIL](SYS_LOAD_DETAIL.md)。SYS 监控视图中的数据经过格式化处理，便于使用和理解。

## 表列
<a name="r_STL_LOAD_COMMITS-table-columns"></a>


| 列名称  | 数据类型  | 描述  | 
| --- | --- | --- | 
| userid | integer | 生成该条目的用户 ID。 | 
| query  | integer | 查询 ID。查询列可用于连接其他系统表和视图。 | 
| slice | integer | 为此条目加载的切片。 | 
| 名称  | character(256)  | System-defined value。 | 
| filename  | character(256)  | 所跟踪的文件的名称。 | 
| byte\_offset  | integer  | 此信息仅供内部使用。 | 
| lines\_scanned  | integer  | 从加载文件中扫描的行数。此数字可能与实际加载的行数不匹配。例如，根据 COPY 命令中的 MAXERROR 选项，加载操作可能会扫描但会容忍大量的错误记录。 | 
| errors  | integer  | 此信息仅供内部使用。 | 
| curtime  | timestamp  | 上次更新此条目的时间。 | 
| status  | integer | 此信息仅供内部使用。 | 
| file\_format  | character(16)  | 加载文件的格式。可能值如下所示：[See the AWS documentation website for more details](http://docs.amazonaws.cn/redshift/latest/dg/r_STL_LOAD_COMMITS.html)  | 
| is\_partial | integer | 值，如果为真 (1) 表示在 COPY 操作期间输入文件被拆分为范围。如果此值为假 (0)，则不会拆分输入文件。 | 
| start\_offset | bigint | 值，如果在 COPY 操作期间拆分输入文件，则表示拆分的偏移值（以字节为单位）。每个文件拆分都记录为具有相应 start\_offset 值的单独记录。如果文件未拆分，则此值为 0。 | 
| copy\_job\_id  | bigint  | 复制作业标识符。0 表示没有作业标识符。 | 

## 示例查询
<a name="r_STL_LOAD_COMMITS-sample-queries"></a>

以下示例返回上次 COPY 操作的详细信息。

```
select query, trim(filename) as file, curtime as updated
from stl_load_commits
where query = pg_last_copy_id();

 query |               file               |          updated           
-------+----------------------------------+----------------------------
 28554 | s3://dw-tickit/category_pipe.txt | 2013-11-01 17:14:52.648486 
(1 row)
```

以下查询包含 TICKIT 数据库中初次加载表时的条目：

```
select query, trim(filename), curtime
from stl_load_commits
where filename like '%tickit%' order by query;
```

```
 query |           btrim           |          curtime           
-------+---------------------------+----------------------------
 22475 | tickit/allusers_pipe.txt  | 2013-02-08 20:58:23.274186 
 22478 | tickit/venue_pipe.txt     | 2013-02-08 20:58:25.070604 
 22480 | tickit/category_pipe.txt  | 2013-02-08 20:58:27.333472 
 22482 | tickit/date2008_pipe.txt  | 2013-02-08 20:58:28.608305 
 22485 | tickit/allevents_pipe.txt | 2013-02-08 20:58:29.99489  
 22487 | tickit/listings_pipe.txt  | 2013-02-08 20:58:37.632939 
 22593 | tickit/allusers_pipe.txt  | 2013-02-08 21:04:08.400491 
 22596 | tickit/venue_pipe.txt     | 2013-02-08 21:04:10.056055 
 22598 | tickit/category_pipe.txt  | 2013-02-08 21:04:11.465049 
 22600 | tickit/date2008_pipe.txt  | 2013-02-08 21:04:12.461502 
 22603 | tickit/allevents_pipe.txt | 2013-02-08 21:04:14.785124 
 22605 | tickit/listings_pipe.txt  | 2013-02-08 21:04:20.170594 

(12 rows)
```

向此系统视图的日志文件写入一个记录的事实并不表示加载操作已作为其所属的事务的一部分成功提交。要验证加载提交，请查询 STL\_UTILITYTEXT 视图并查找与 COPY 事务对应的 COMMIT 记录。例如，此查询基于针对 STL\_UTILITYTEXT 的子查询联接 STL\_LOAD\_COMMITS 和 STL\_QUERY：

```
select l.query,rtrim(l.filename),q.xid
from stl_load_commits l, stl_query q
where l.query=q.query
and exists
(select xid from stl_utilitytext where xid=q.xid and rtrim("text")='COMMIT');

 query |           rtrim           |  xid
-------+---------------------------+-------
 22600 | tickit/date2008_pipe.txt  | 68311
 22480 | tickit/category_pipe.txt  | 68066
  7508 | allusers_pipe.txt         | 23365
  7552 | category_pipe.txt         | 23415
  7576 | allevents_pipe.txt        | 23429
  7516 | venue_pipe.txt            | 23390
  7604 | listings_pipe.txt         | 23445
 22596 | tickit/venue_pipe.txt     | 68309
 22605 | tickit/listings_pipe.txt  | 68316
 22593 | tickit/allusers_pipe.txt  | 68305
 22485 | tickit/allevents_pipe.txt | 68071
  7561 | allevents_pipe.txt        | 23429
  7541 | category_pipe.txt         | 23415
  7558 | date2008_pipe.txt         | 23428
 22478 | tickit/venue_pipe.txt     | 68065
   526 | date2008_pipe.txt         |  2572
  7466 | allusers_pipe.txt         | 23365
 22482 | tickit/date2008_pipe.txt  | 68067
 22598 | tickit/category_pipe.txt  | 68310
 22603 | tickit/allevents_pipe.txt | 68315
 22475 | tickit/allusers_pipe.txt  | 68061
   547 | date2008_pipe.txt         |  2572
 22487 | tickit/listings_pipe.txt  | 68072
  7531 | venue_pipe.txt            | 23390
  7583 | listings_pipe.txt         | 23445
(25 rows)
```

以下示例突出显示 is\_partial 和 start\_offset 列值。

```
-- Single large file copy without scan range
SELECT count(*) FROM stl_load_commits WHERE query = pg_last_copy_id();
1

-- Single large uncompressed, delimited file copy with scan range
SELECT count(*) FROM stl_load_commits WHERE query = pg_last_copy_id();
16

-- Scan range offset logging in the file at 64MB boundary. 
SELECT start_offset FROM stl_load_commits
WHERE query = pg_last_copy_id() ORDER BY start_offset;
0
67108864
134217728
201326592
268435456
335544320
402653184
469762048
536870912
603979776
671088640
738197504
805306368
872415232
939524096
1006632960
```