

 从补丁 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/)。

# SYS\_AUTO\_TABLE\_OPTIMIZATION
<a name="r_SYS_AUTO_TABLE_OPTIMIZATION"></a>

记录 Amazon Redshift 对自动优化定义的表执行的自动操作。

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

## 表列
<a name="r_SYS_AUTO_TABLE_OPTIMIZATION-table-rows"></a>


| 列名称  | 数据类型  | 说明  | 
| --- | --- | --- | 
| transaction\_id  | 长整数 | 事务标识符。 | 
| session\_id  | int  | 执行 Alter 命令的进程的标识符。 | 
| table\_id  | int  | 表标识符。 | 
| alter\_table\_type | character(32)  | 建议的类型。可能的值为 distkey、sortkey 和 encode。 | 
| status  | character(128)  | 建议的完成状态。可能的值包括 Start、Complete、Skipped、Abort、Checkpoint 和 Failed。 | 
| event\_time  | timestamp  | 状态列的时间戳。 | 
| alter\_from  | character(200)  | 应用建议之前表的上一个分配方式和排序键。该值被截断为 200 个字符的增量。 | 

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

在以下示例中，结果中的行显示了由 Amazon Redshift 执行的操作。

```
SELECT table_id, alter_table_type, status, event_time, alter_from
FROM SYS_AUTO_TABLE_OPTIMIZATION;
                
 table_id |  alter_table_type   |                        status                        |         event_time          |  alter_from
----------+---------------------+------------------------------------------------------+-----------------------------+-----------------
   118082 | sortkey             | Start                                                | 2020-08-22 19:42:20.727049  | 
   118078 | sortkey             | Start                                                | 2020-08-22 19:43:54.728819  | 
   118082 | sortkey             | Start                                                | 2020-08-22 19:42:52.690264  | 
   118072 | sortkey             | Start                                                | 2020-08-22 19:44:14.793572  | 
   118082 | sortkey             | Failed                                               | 2020-08-22 19:42:20.728917  | 
   118078 | sortkey             | Complete                                             | 2020-08-22 19:43:54.792705  |  SORTKEY: None;
   118086 | sortkey             | Complete                                             | 2020-08-22 19:42:00.72635   |  SORTKEY: None;
   118082 | sortkey             | Complete                                             | 2020-08-22 19:43:34.728144  |  SORTKEY: None;
   118072 | sortkey             | Skipped:Retry exceeds the maximum limit for a table. | 2020-08-22 19:44:46.706155  | 
   118086 | sortkey             | Start                                                | 2020-08-22 19:42:00.685255  | 
   118082 | sortkey             | Start                                                | 2020-08-22 19:43:34.69531   | 
   118072 | sortkey             | Start                                                | 2020-08-22 19:44:46.703331  | 
   118082 | sortkey             | Checkpoint: progress 14.755079%                      | 2020-08-22 19:42:52.692828  | 
   118072 | sortkey             | Failed                                               | 2020-08-22 19:44:14.796071  |   
   116723 | sortkey             | Abort:This table is not AUTO.                        | 2020-10-28 05:12:58.479233  | 
   110203 | distkey             | Abort:This table is not AUTO.                        | 2020-10-28 05:45:54.67259   |
```