amazon-redshift - 评估 Redshift 中的 VACUUM 将释放多少空间

标签 amazon-redshift

根据 AWS 文档:

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

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

谢谢

引用资料:

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 中的 tbl_rows 列来计算将从 vacuum 命令中释放的存储量。看法。这包括标记为删除的行。将其与同一张表中的 select count(*) 进行比较,您将得到一个比率。在名为 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 和游标,因此要在所有表中获得相同的比率,您必须从外部源或编程语言(即 python)执行代码。

关于amazon-redshift - 评估 Redshift 中的 VACUUM 将释放多少空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34395413/

相关文章:

sql - 从 SQL 中的时间戳中提取时间

sql - Redshift - 过去一小时值的窗口函数

sql - 如何在 Amazon Redshift 中选择多个填充常量的行?

amazon-redshift - 为什么 Redshift COPY 查询为带有排序键的表使用(更多)磁盘空间

sql - 如何有效地将不同的值计入SQL中的不同行?

python - 亚马逊 Redshift : How can I convert a 15 char Salesforce Id value into an 18 char Id value

sql - 在亚马逊 Redshift 中取消列出一个数组

amazon-web-services - 使用 AWS Pipeline 从 S3 传输到 RedShift 时展平 JSON 文件

amazon-web-services - Redshift 复制命令递归扫描

postgresql - 在 Redshift 中创建 View 时有什么方法可以强制后期绑定(bind)吗?