

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

# STL\$1VACUUM
<a name="r_STL_VACUUM"></a>

显示已真空化的表的行和数据块统计数据。

该视图显示了特定于每个 vacuum 操作开始和完成时的信息，并演示了运行此操作的好处。有关运行该命令的要求的信息，请参阅 [VACUUM](r_VACUUM_command.md) 命令描述。

STL\$1VACUUM 仅对超级用户可见。有关更多信息，请参阅 [系统表和视图中的数据可见性](cm_chap_system-tables.md#c_visibility-of-data)。

此表中的部分或全部数据也可以在 SYS 监控视图 [SYS\$1VACUUM\$1HISTORY](SYS_VACUUM_HISTORY.md) 中找到。SYS 监控视图中的数据经过格式化处理，便于使用和理解。我们建议您使用 SYS 监控视图进行查询。

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/dg/r_STL_VACUUM.html)

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

以下查询报告表 108313 的 vacuum 统计数据。此表在一系列插入和删除后已执行 vacuum 操作。

```
select xid, table_id, status, rows, sortedrows, blocks, eventtime,
                reclaimable_rows, reclaimable_space_mb
from stl_vacuum where table_id=108313 order by eventtime;

 xid   | table_id | status                  | rows | sortedrows | blocks |  eventtime           | reclaimable_rows | reclaimable_space_mb 
-------+----------+-------------------------+------+------------+--------+----------------------+------------------+----------------------
 14294 |   108313 | Started                 | 1950 |        408 |     28 |  2016-05-19 17:36:01 |              984 |                   17          
 14294 |   108313 | Finished                |  966 |        966 |     11 |  2016-05-19 18:26:13 |                0 |                    0 
 15126 |   108313 | Skipped(sorted>=95%)    |  966 |        966 |     11 |  2016-05-19 18:26:38 |                0 |                    0
```

在 VACUUM 启动时，表包含了存储在 28 个 1MB 数据块中的 1,950 行。Amazon Redshift 估计，它可以通过 vacuum 操作回收 984 行或 17 个数据块的磁盘空间。

在状态为“完成”的行中，ROWS 列显示值 966，而 BLOCKS 列值为 11，低于 28。vacuum 回收了估计的磁盘空间量，在 vacuum 操作完成后，没有剩余可回收的行或空间。

在排序阶段（事务 15126），vacuum 无法跳过此表，因为行是按排序键顺序插入的。

以下示例显示在大型 INSERT 操作之后，针对 SALES 表（在此示例中为表 110116）的 SORT ONLY vacuum 操作的统计数据：

```
vacuum sort only sales;

select xid, table_id, status, rows, sortedrows, blocks, eventtime
from stl_vacuum order by xid, table_id, eventtime;

xid |table_id|     status      | rows  |sortedrows|blocks|     eventtime
----+--------+-----------------+-------+----------+------+--------------------
...
2925| 110116 |Started Sort Only|1379648|   172456 |  132 | 2011-02-24 16:25:21...
2925| 110116 |Finished         |1379648|  1379648 |  132 | 2011-02-24 16:26:28...
```