

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

# STV\$1BLOCKLIST
<a name="r_STV_BLOCKLIST"></a>

STV\$1BLOCKLIST 包含数据库中每个分片、表或列所使用的 1 MB 磁盘块的数目。

将聚合查询与 STV\$1BLOCKLIST 结合使用（如以下示例所示）可确定为每个数据库、表、分片或列分配的 1 MB 磁盘块的数目。您还可以使用 [STV\$1PARTITIONS](r_STV_PARTITIONS.md) 查看有关磁盘利用率的摘要信息。

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

**注意**  
 STV\$1BLOCKLIST 仅记录由预置集群或无服务器命名空间拥有的块。如果数据库包含从数据共享创建者共享的块，则这些块不会包含在 STV\$1BLOCKLIST 中。有关数据共享的更多信息，请转至[Amazon Redshift 中的数据共享](datashare-overview.md)。

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

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

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

分配的每个磁盘块在 STV\$1BLOCKLIST 中对应一行，因此选择所有行的查询可能会返回非常多的行。建议仅将聚合查询与 STV\$1BLOCKLIST 结合使用。

[SVV\$1DISKUSAGE](r_SVV_DISKUSAGE.md) 视图以对用户更友好的格式提供相似信息；而以下示例演示 STV\$1BLOCKLIST 表的一个用例。

要确定 VENUE 表中每一列所使用的 1 MB 块数，请键入以下查询：

```
select col, count(*)
from stv_blocklist, stv_tbl_perm
where stv_blocklist.tbl = stv_tbl_perm.id
and stv_blocklist.slice = stv_tbl_perm.slice
and stv_tbl_perm.name = 'venue'
group by col
order by col;
```

此查询返回分配到 VENUE 表中每一列的 1 MB 块的数目，如以下示例数据所示：

```
 col | count
-----+-------
   0 |  4
   1 |  4
   2 |  4
   3 |  4
   4 |  4
   5 |  4
   7 |  4
   8 |  4
(8 rows)
```

以下查询显示表数据是否实际分布于所有分片间：

```
select trim(name) as table, stv_blocklist.slice, stv_tbl_perm.rows
from stv_blocklist,stv_tbl_perm
where stv_blocklist.tbl=stv_tbl_perm.id
and stv_tbl_perm.slice=stv_blocklist.slice
and stv_blocklist.id > 10000 and name not like '%#m%'
and name not like 'systable%'
group by name, stv_blocklist.slice, stv_tbl_perm.rows
order by 3 desc;
```

此查询生成以下示例输出，其中显示行数最多的表的平均数据分布：

```
table   | slice | rows
----------+-------+-------
listing  |    13 | 10527
listing  |    14 | 10526
listing  |     8 | 10526
listing  |     9 | 10526
listing  |     7 | 10525
listing  |     4 | 10525
listing  |    17 | 10525
listing  |    11 | 10525
listing  |     5 | 10525
listing  |    18 | 10525
listing  |    12 | 10525
listing  |     3 | 10525
listing  |    10 | 10525
listing  |     2 | 10524
listing  |    15 | 10524
listing  |    16 | 10524
listing  |     6 | 10524
listing  |    19 | 10524
listing  |     1 | 10523
listing  |     0 | 10521
...
(180 rows)
```

以下查询确定是否向磁盘提交了任何已逻辑删除的块：

```
select slice, col, tbl, blocknum, newblock
from stv_blocklist
where  tombstone > 0;

slice | col |   tbl  | blocknum | newblock
-------+-----+--------+----------+----------
4     |  0  | 101285 |    0     |   1
4     |  2  | 101285 |    0     |   1
4     |  4  | 101285 |    1     |   1
5     |  2  | 101285 |    0     |   1
5     |  0  | 101285 |    0     |   1
5     |  1  | 101285 |    0     |   1
5     |  4  | 101285 |    1     |   1
...
(24 rows)
```