

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

# SVV\$1DISKUSAGE
SVV\$1DISKUSAGE

Amazon Redshift 通过联接 STV\$1TBL\$1PERM 和 STV\$1BLOCKLIST 表来创建 SVV\$1DISKUSAGE 系统视图。SVV\$1DISKUSAGE 视图包含数据库中表的数据分配的相关信息。

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

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

**注意**  
此视图仅在查询预置集群时可用。

## 表列
表列

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/r_SVV_DISKUSAGE.html)

## 示例查询
示例查询

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

返回曾经分配到 USERS 表中第 6 列（EMAIL 列）的最大数据块数。

```
select db_id, trim(name) as tablename, max(blocknum)
from svv_diskusage
where name='users' and col=6
group by db_id, name;

db_id  | tablename | max
--------+-----------+-----
175857 | users     |   2
(1 row)
```

对于名为 SALESNEW 的 10 列大型表中的所有列，下面的查询返回相似的结果。（列 10 到 12 的最后三行用于隐藏元数据列。） 

```
select db_id, trim(name) as tablename, col, tbl, max(blocknum)
from svv_diskusage
where name='salesnew'
group by db_id, name, col, tbl
order by db_id, name, col, tbl;

db_id  | tablename  | col |  tbl   | max
--------+------------+-----+--------+-----
175857 | salesnew   |   0 | 187605 | 154
175857 | salesnew   |   1 | 187605 | 154
175857 | salesnew   |   2 | 187605 | 154
175857 | salesnew   |   3 | 187605 | 154
175857 | salesnew   |   4 | 187605 | 154
175857 | salesnew   |   5 | 187605 |  79
175857 | salesnew   |   6 | 187605 |  79
175857 | salesnew   |   7 | 187605 | 302
175857 | salesnew   |   8 | 187605 | 302
175857 | salesnew   |   9 | 187605 | 302
175857 | salesnew   |  10 | 187605 |   3
175857 | salesnew   |  11 | 187605 |   2
175857 | salesnew   |  12 | 187605 | 296
(13 rows)
```