

 从补丁 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\_ANALYZE\_COMPRESSION\_HISTORY
<a name="r_SYS_ANALYZE_COMPRESSION_HISTORY"></a>

记录在 COPY 或 ANALYZE COMPRESSION 命令期间压缩分析操作的详细信息。

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

## 表列
<a name="r_SYS_ANALYZE_COMPRESSION_HISTORY-table-columns2"></a>


| 列名称  | 数据类型  | 描述  | 
| --- | --- | --- | 
| user\_id | 整数 | 生成该条目的用户的 ID。 | 
| start\_time | timestamp | 开始压缩分析操作的时间。 | 
| transaction\_id | bigint | 压缩分析操作的事务 ID。 | 
| table\_id | 整数 | 所分析的表的表 ID。 | 
| table\_name | character(128) | 所分析的表的名称。 | 
| column\_position | 整数 | 表中进行分析以确定压缩编码的列的索引。 | 
| old\_encoding | character(15) | 压缩分析之前的编码类型。 | 
| new\_encoding | character(15) | 压缩分析之后的编码类型。 | 
| mode | character(14) | [See the AWS documentation website for more details](http://docs.amazonaws.cn/redshift/latest/dg/r_SYS_ANALYZE_COMPRESSION_HISTORY.html)  | 

## 示例查询
<a name="r_SYS_ANALYZE_COMPRESSION_HISTORY-sample-queries2"></a>

以下示例检查在同一个会话中运行的最后一个 COPY 命令对 `lineitem` 表执行压缩分析的详细信息。

```
select transaction_id, table_id, btrim(table_name) as table_name, column_position, old_encoding, new_encoding, mode 
from sys_analyze_compression_history
where transaction_id = (select transaction_id from sys_query_history where query_id = pg_last_copy_id()) order by column_position;
                
 transaction_id  |  table_id   | table_name | column_position |  old_encoding   |  new_encoding   |      mode
-----------------+-------------+------------+-----------------+-----------------+-----------------+-------------
      8196       |   248126    | lineitem   |        0        | mostly32        | mostly32        | ON
      8196       |   248126    | lineitem   |        1        | mostly32        | lzo             | ON
      8196       |   248126    | lineitem   |        2        | lzo             | delta32k        | ON
      8196       |   248126    | lineitem   |        3        | delta           | delta           | ON
      8196       |   248126    | lineitem   |        4        | bytedict        | bytedict        | ON
      8196       |   248126    | lineitem   |        5        | mostly32        | mostly32        | ON
      8196       |   248126    | lineitem   |        6        | delta           | delta           | ON
      8196       |   248126    | lineitem   |        7        | delta           | delta           | ON
      8196       |   248126    | lineitem   |        8        | lzo             | zstd            | ON
      8196       |   248126    | lineitem   |        9        | runlength       | zstd            | ON
      8196       |   248126    | lineitem   |       10        | delta           | lzo             | ON
      8196       |   248126    | lineitem   |       11        | delta           | delta           | ON
      8196       |   248126    | lineitem   |       12        | delta           | delta           | ON
      8196       |   248126    | lineitem   |       13        | bytedict        | zstd            | ON
      8196       |   248126    | lineitem   |       14        | bytedict        | zstd            | ON
      8196       |   248126    | lineitem   |       15        | text255         | zstd            | ON
(16 rows)
```