评估 Redshift 中的 VACUUM 将释放多少 space

Evaluate how much space will be freed by VACUUM in Redshift

根据 AWS 文档:

Amazon Redshift does not automatically reclaim and reuse space that is freed when you delete rows and update rows.

在 运行 VACUUM 之前,有没有办法知道或评估 VACUUM 将从磁盘中释放多少 space?

感谢

参考文献:

http://docs.aws.amazon.com/redshift/latest/dg/t_Reclaiming_storage_space202.html http://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html

这不是一种非常准确的方法,但您可以查询 svv_table_info 并查找列 deleted_pct。这将使您大致了解 table 中有多少部分需要使用 vacuum 重建。

您可以 运行 为系统中的所有 table 获取整个系统的估算值。

您可以通过查找 svv_table_info 视图中的 tbl_rows 列来计算将从 vacuum 命令中释放的存储量。这包括标记为删除的行。将其与来自相同 table 的 select count(*) 进行比较,您将得到一个比率。理论上 table 名为 factsales.

的类似内容
select    (select cast(count(*) as numeric(12,0)) from factsales) /
    cast(tbl_rows as numeric(12,0))
    as "percentage of non deleted rows" 
    from svv_table_info where "table" = 'factsales'

似乎没有一种直接的方法来执行动态 SQL 和游标,因此要在所有 table 中获得相同的比率,您必须从外部执行代码源代码或编程语言,即 python.