

 从补丁 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\$1UNIQUE
<a name="r_STL_UNIQUE"></a>

分析在 SELECT 列表中使用 DISTINCT 函数时或者在 UNION 或 INTERSECT 查询中删除重复项时发生的执行步骤。

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

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

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

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

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

假设您运行以下查询：

```
select distinct eventname
from event order by 1;
```

假定上个查询的 ID 是 6313，以下示例显示由分段 0 和 1 中每个切片的唯一步骤生成的行的数量。

```
select query, slice, segment, step, datediff(msec, starttime, endtime) as msec, tasknum, rows 
from stl_unique where query = 6313
order by query desc, slice, segment, step;
```

```
 query | slice | segment | step | msec | tasknum | rows
-------+-------+---------+------+------+---------+------
  6313 |     0 |       0 |    2 |    0 |      22 |  550
  6313 |     0 |       1 |    1 |  256 |      20 |  145
  6313 |     1 |       0 |    2 |    1 |      23 |  540
  6313 |     1 |       1 |    1 |   42 |      21 |  127
  6313 |     2 |       0 |    2 |    1 |      22 |  540
  6313 |     2 |       1 |    1 |  255 |      20 |  158
  6313 |     3 |       0 |    2 |    1 |      23 |  542
  6313 |     3 |       1 |    1 |   38 |      21 |  146
(8 rows)
```